Package top.focess.util.option.type
Class OptionType<T>
- java.lang.Object
-
- top.focess.util.option.type.OptionType<T>
-
- Type Parameters:
T- the target type
- Direct Known Subclasses:
ExceptionOptionType
public abstract class OptionType<T> extends Object
This class is used to define the type of argument
-
-
Field Summary
Fields Modifier and Type Field Description static OptionType<String>DEFAULT_OPTION_TYPEAccept all values
-
Constructor Summary
Constructors Constructor Description OptionType()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract booleanaccept(String v)Indicate whether this type can accept the value.abstract Tparse(String v)Parse the value to the target type.
-
-
-
Field Detail
-
DEFAULT_OPTION_TYPE
public static final OptionType<String> DEFAULT_OPTION_TYPE
Accept all values
-
-
Method Detail
-
parse
public abstract T parse(String v)
Parse the value to the target type. Note: called only whenaccept(String)return true.- Parameters:
v- the value- Returns:
- the target type
-
accept
public abstract boolean accept(String v)
Indicate whether this type can accept the value.- Parameters:
v- the value- Returns:
- true if can accept, false otherwise
-
-