Package top.focess.qq.api.command
Class DataConverter<T>
- java.lang.Object
-
- top.focess.qq.api.command.DataConverter<T>
-
- Type Parameters:
T- target type
- Direct Known Subclasses:
ExceptionDataConverter,NullDataConverter
public abstract class DataConverter<T> extends Object
This class used to convert String data to target T type data.
-
-
Field Summary
Fields Modifier and Type Field Description static DataConverter<Boolean>BOOLEAN_DATA_CONVERTERConvert the String argument to Boolean argumentstatic DataConverter<String>DEFAULT_DATA_CONVERTERNever convert it! Put them into DataCollection with their original values.static DataConverter<Double>DOUBLE_DATA_CONVERTERConvert the String argument to Double argumentstatic java.util.function.Predicate<String>DOUBLE_PREDICATEIt is a Predicate used to predicate a String is a Doublestatic DataConverter<Integer>INTEGER_DATA_CONVERTERConvert the String argument to Integer argumentstatic java.util.function.Predicate<String>INTEGER_PREDICATEIt is a Predicate used to predicate a String is an Integerstatic DataConverter<Long>LONG_DATA_CONVERTERConvert the String argument to Long argumentstatic java.util.function.Predicate<String>LONG_PREDICATEIt is a Predicate used to predicate a String is a Long
-
Constructor Summary
Constructors Constructor Description DataConverter()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description protected abstract booleanaccept(String arg)Indicate whether this String argument is this target type or notprotected abstract voidconnect(DataCollection dataCollection, T arg)Used to put data into the dataCollectionabstract Tconvert(String arg)Convert String argument to target argumentprotected abstract Class<T>getTargetClass()
-
-
-
Field Detail
-
INTEGER_PREDICATE
public static final java.util.function.Predicate<String> INTEGER_PREDICATE
It is a Predicate used to predicate a String is an Integer
-
DOUBLE_PREDICATE
public static final java.util.function.Predicate<String> DOUBLE_PREDICATE
It is a Predicate used to predicate a String is a Double
-
LONG_PREDICATE
public static final java.util.function.Predicate<String> LONG_PREDICATE
It is a Predicate used to predicate a String is a Long
-
DEFAULT_DATA_CONVERTER
public static final DataConverter<String> DEFAULT_DATA_CONVERTER
Never convert it! Put them into DataCollection with their original values.
-
INTEGER_DATA_CONVERTER
public static final DataConverter<Integer> INTEGER_DATA_CONVERTER
Convert the String argument to Integer argument
-
LONG_DATA_CONVERTER
public static final DataConverter<Long> LONG_DATA_CONVERTER
Convert the String argument to Long argument
-
DOUBLE_DATA_CONVERTER
public static final DataConverter<Double> DOUBLE_DATA_CONVERTER
Convert the String argument to Double argument
-
BOOLEAN_DATA_CONVERTER
public static final DataConverter<Boolean> BOOLEAN_DATA_CONVERTER
Convert the String argument to Boolean argument
-
-
Method Detail
-
accept
protected abstract boolean accept(String arg)
Indicate whether this String argument is this target type or not- Parameters:
arg- the target argument in String- Returns:
- true if this String argument can convert to this target type, false otherwise
-
convert
public abstract T convert(String arg)
Convert String argument to target argument- Parameters:
arg- the target argument in String- Returns:
- the target argument
-
connect
protected abstract void connect(DataCollection dataCollection, T arg)
Used to put data into the dataCollection- Parameters:
dataCollection- where stores the dataarg- the target argument- See Also:
DataCollection.write(Class, Object)
-
-