public interface ICommandArgument
ICommandArgument
is an immutable object representing one command argument. It contains data on the index of
that argument, its value, and the rest of the string that argument was found in
You're recommended to use IArgConsumer
}s to handle these.
Modifier and Type | Method and Description |
---|---|
<T> T |
getAs(java.lang.Class<T> type)
Tries to use a stateless
IArgParser to parse this argument into the specified class |
<T,S> T |
getAs(java.lang.Class<T> type,
java.lang.Class<S> stateType,
S state)
Tries to use a stated
IArgParser to parse this argument into the specified class |
<E extends java.lang.Enum<?>> |
getEnum(java.lang.Class<E> enumClass)
Gets an enum value from the enum class with the same name as this argument's value
|
int |
getIndex() |
java.lang.String |
getRawRest() |
java.lang.String |
getValue() |
<T> boolean |
is(java.lang.Class<T> type)
Tries to use a stateless
IArgParser to parse this argument into the specified class |
<T,S> boolean |
is(java.lang.Class<T> type,
java.lang.Class<S> stateType,
S state)
Tries to use a stated
IArgParser to parse this argument into the specified class |
int getIndex()
java.lang.String getValue()
java.lang.String getRawRest()
<E extends java.lang.Enum<?>> E getEnum(java.lang.Class<E> enumClass) throws CommandInvalidTypeException
For example if you getEnum as an EnumFacing
, and this argument's value is "up", it will return EnumFacing.UP
enumClass
- The enum class to searchCommandInvalidTypeException
- If the constant couldn't be foundIArgConsumer.peekEnum(Class)
,
IArgConsumer.peekEnum(Class, int)
,
IArgConsumer.peekEnumOrNull(Class)
,
IArgConsumer.peekEnumOrNull(Class, int)
,
IArgConsumer.getEnum(Class)
,
IArgConsumer.getEnumOrNull(Class)
<T> T getAs(java.lang.Class<T> type) throws CommandInvalidTypeException
IArgParser
to parse this argument into the specified classtype
- The class to parse this argument intoCommandInvalidTypeException
- If the parsing failed<T> boolean is(java.lang.Class<T> type)
IArgParser
to parse this argument into the specified classtype
- The class to parse this argument into<T,S> T getAs(java.lang.Class<T> type, java.lang.Class<S> stateType, S state) throws CommandInvalidTypeException
IArgParser
to parse this argument into the specified classtype
- The class to parse this argument intoCommandInvalidTypeException
- If the parsing failed<T,S> boolean is(java.lang.Class<T> type, java.lang.Class<S> stateType, S state)
IArgParser
to parse this argument into the specified classtype
- The class to parse this argument into