Package top.focess.qq.api.command
Class DataCollection
- java.lang.Object
-
- top.focess.qq.api.command.DataCollection
-
public class DataCollection extends Object
Store and parser arguments for better CommandExecutor usage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDataCollection.BufferGetterRepresents a getter for buffer.
-
Constructor Summary
Constructors Constructor Description DataCollection(DataConverter<?>[] dataConverters)Initialize the DataCollection with fixed size.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringget()Get String argument in order<T> Tget(Class<T> c)Get buffer element<T> Tget(Class<T> c, int index)Get buffer elementbooleangetBoolean()Get boolean argument in orderCommandgetCommand()Get Command argument in orderdoublegetDouble()Get double argument in orderintgetInt()Get int argument in orderlonggetLong()Get long argument in order<T> TgetOrDefault(Class<T> cls, int index, T t)Get buffer element<T> TgetOrDefault(Class<T> cls, T t)Get buffer elementPlugingetPlugin()Get Plugin argument in orderstatic voidregister(Plugin plugin, DataConverter<?> dataConverter, DataCollection.BufferGetter bufferGetter)Register the getter of the bufferstatic voidunregister(Plugin plugin)Unregister the getter of the buffers by pluginstatic booleanunregisterAll()Unregister all the getter of the buffers
-
-
-
Constructor Detail
-
DataCollection
public DataCollection(DataConverter<?>[] dataConverters)
Initialize the DataCollection with fixed size.- Parameters:
dataConverters- the data converters
-
-
Method Detail
-
register
public static void register(Plugin plugin, DataConverter<?> dataConverter, DataCollection.BufferGetter bufferGetter)
Register the getter of the buffer- Parameters:
plugin- the plugindataConverter- the buffer data converterbufferGetter- the getter of the buffer
-
unregister
public static void unregister(Plugin plugin)
Unregister the getter of the buffers by plugin- Parameters:
plugin- the plugin
-
unregisterAll
public static boolean unregisterAll()
Unregister all the getter of the buffers- Returns:
- true if there are some getter of the buffers not belonging to MainPlugin not been unregistered, false otherwise
-
get
public String get()
Get String argument in order- Returns:
- the String argument in order
-
getInt
public int getInt()
Get int argument in order- Returns:
- the int argument in order
-
getDouble
public double getDouble()
Get double argument in order- Returns:
- the double argument in order
-
getBoolean
public boolean getBoolean()
Get boolean argument in order- Returns:
- the boolean argument in order
-
getLong
public long getLong()
Get long argument in order- Returns:
- the long argument in order
-
getPlugin
public Plugin getPlugin()
Get Plugin argument in order- Returns:
- the Plugin argument in order
-
getCommand
public Command getCommand()
Get Command argument in order- Returns:
- the Command argument in order
-
getOrDefault
public <T> T getOrDefault(Class<T> cls, T t)
Get buffer element- Type Parameters:
T- the buffer elements' type- Parameters:
cls- the buffer elements' classt- the default value- Returns:
- the buffer element
- Throws:
UnsupportedOperationException- if the buffer is not registered
-
getOrDefault
public <T> T getOrDefault(Class<T> cls, int index, T t)
Get buffer element- Type Parameters:
T- the buffer elements' type- Parameters:
cls- the buffer elements' classt- the default valueindex- the buffer element index- Returns:
- the buffer element
- Throws:
UnsupportedOperationException- if the buffer is not registered
-
get
public <T> T get(Class<T> c)
Get buffer element- Type Parameters:
T- the buffer elements' type- Parameters:
c- the buffer elements' class- Returns:
- the buffer element
- Throws:
UnsupportedOperationException- if the buffer is not registered
-
get
public <T> T get(Class<T> c, int index)
Get buffer element- Type Parameters:
T- the buffer elements' type- Parameters:
index- the buffer element indexc- the buffer elements' class- Returns:
- the buffer element
- Throws:
UnsupportedOperationException- if the buffer is not registered
-
-