Interface Value
- All Superinterfaces:
Expression, Logical
A value is a
logical expression which evaluates to itself.- Author:
- Stephen G. Ware
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidconfigure(com.google.gson.GsonBuilder builder) Configures aGsonBuilderto encode and decodeValueobjects as JSON.default ValueReturns the value of this logical expression in the given state.default Valuesubstitute(Function<Object, Object> substitution) Returns a logical object identical to this one, except that its logical elements have been replaced according to the given substitution.default booleanIf this value represents a Boolean, this method convert it into a Javaboolean; all other values are converted tofalse.default EntitytoEntity()If this value represents anEntity, this method returns that entity; all other values are converted to {code null}.default doubletoNumber()If this value represents a number, this method convert it into a Javadouble; all other values are converted toDouble.NaN.
-
Method Details
-
configure
static void configure(com.google.gson.GsonBuilder builder) Configures aGsonBuilderto encode and decodeValueobjects as JSON.- Parameters:
builder- the GSON builder to configure
-
substitute
Description copied from interface:LogicalReturns a logical object identical to this one, except that its logical elements have been replaced according to the given substitution. A substitution defines how some logical formula (the input to the function) should be replaced with a different formula (the output of the function).- Specified by:
substitutein interfaceExpression- Specified by:
substitutein interfaceLogical- Parameters:
substitution- a function which maps logical formula that should be replaced to the formula they should be replaced with- Returns:
- an identical object, except that its logical formula have been replaced according to the substitution
-
evaluate
Returns the value of this logical expression in the given state.A logical value evaluates to itself.
- Specified by:
evaluatein interfaceExpression- Parameters:
state- a mapping of values to all of a story world's variables- Returns:
- the value of the expression in the given state
-
toBoolean
default boolean toBoolean()If this value represents a Boolean, this method convert it into a Javaboolean; all other values are converted tofalse.- Returns:
- a Java
boolean, orfalseif this value does not represent a Boolean value
-
toNumber
default double toNumber()If this value represents a number, this method convert it into a Javadouble; all other values are converted toDouble.NaN.- Returns:
- a Java
double, or NaN if this value represents NaN or is not a number
-
toEntity
-