Package com.gengoai.parsing
Class ValueExpression
- java.lang.Object
-
- com.gengoai.parsing.BaseExpression
-
- com.gengoai.parsing.ValueExpression
-
- All Implemented Interfaces:
Expression
,Serializable
public class ValueExpression extends BaseExpression
Generic value expression in which the value is stored using aVal
to support arbitrary types.- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static PrefixHandler
BOOLEAN_HANDLER
Creates a boolean value handler which will parse theParserToken
text to generate the boolean valuestatic PrefixHandler
NULL_HANDLER
Creates a null value handler which will always contain a null valuestatic PrefixHandler
NUMERIC_HANDLER
Creates a numeric value handler which will parse theParserToken
text usingDouble.parseDouble
to generate the numeric valuestatic PrefixHandler
STRING_HANDLER
Creates a string value handler which will use the text of theParserToken
as the value
-
Constructor Summary
Constructors Constructor Description ValueExpression(Tag type, Object value)
Instantiates a new Value expression.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Val
getValue()
Gets the stored value<T> T
getValue(Class<T> tClass)
Gets the value as the given typestatic PrefixHandler
handler(SerializableFunction<ParserToken,Object> converter)
Creates a generic handler which uses the givenSerializableFunction
to convert theParserToken
to a value.int
hashCode()
String
toString()
-
Methods inherited from class com.gengoai.parsing.BaseExpression
getType
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.gengoai.parsing.Expression
apply, as, isInstance, isInstance, isInstance, when, when
-
-
-
-
Field Detail
-
BOOLEAN_HANDLER
public static final PrefixHandler BOOLEAN_HANDLER
Creates a boolean value handler which will parse theParserToken
text to generate the boolean value
-
NULL_HANDLER
public static final PrefixHandler NULL_HANDLER
Creates a null value handler which will always contain a null value
-
NUMERIC_HANDLER
public static final PrefixHandler NUMERIC_HANDLER
Creates a numeric value handler which will parse theParserToken
text usingDouble.parseDouble
to generate the numeric value
-
STRING_HANDLER
public static final PrefixHandler STRING_HANDLER
Creates a string value handler which will use the text of theParserToken
as the value
-
-
Method Detail
-
handler
public static PrefixHandler handler(SerializableFunction<ParserToken,Object> converter)
Creates a generic handler which uses the givenSerializableFunction
to convert theParserToken
to a value.- Parameters:
converter
- the converter to convert the token into a value.- Returns:
- the prefix handler
-
getValue
public Val getValue()
Gets the stored value- Returns:
- the value
-
getValue
public <T> T getValue(Class<T> tClass)
Gets the value as the given type- Type Parameters:
T
- the type parameter- Parameters:
tClass
- the class information of the type to return- Returns:
- the value
-
-