Class Value
- java.lang.Object
-
- software.amazon.smithy.rulesengine.language.evaluation.value.Value
-
- All Implemented Interfaces:
FromSourceLocation
,ToNode
- Direct Known Subclasses:
ArrayValue
,BooleanValue
,EmptyValue
,EndpointValue
,IntegerValue
,RecordValue
,StringValue
public abstract class Value extends java.lang.Object implements FromSourceLocation, ToNode
An abstract representing a typed value.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ArrayValue
arrayValue(java.util.List<Value> value)
Creates anArrayValue
from a list of values.static BooleanValue
booleanValue(boolean value)
Creates anBooleanValue
from a boolean.static EmptyValue
emptyValue()
Creates anEmptyValue
.static EndpointValue
endpointValue(Node source)
Creates anEndpointValue
from a node.ArrayValue
expectArrayValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.BooleanValue
expectBooleanValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.EndpointValue
expectEndpointValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.IntegerValue
expectIntegerValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.RecordValue
expectRecordValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.StringValue
expectStringValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.static Value
fromNode(Node source)
Creates aValue
of a specific type from the given Node information.SourceLocation
getSourceLocation()
Gets the source location of a value.abstract Type
getType()
static IntegerValue
integerValue(int value)
Creates anIntegerValue
from an integer.boolean
isEmpty()
static RecordValue
recordValue(java.util.Map<Identifier,Value> value)
Creates anRecordValue
from a map of identifiers to values.static StringValue
stringValue(java.lang.String value)
Creates anStringValue
from a string.
-
-
-
Method Detail
-
getType
public abstract Type getType()
-
fromNode
public static Value fromNode(Node source)
Creates aValue
of a specific type from the given Node information.- Parameters:
source
- the node to deserialize.- Returns:
- the created Value.
-
isEmpty
public boolean isEmpty()
-
getSourceLocation
public SourceLocation getSourceLocation()
Description copied from interface:FromSourceLocation
Gets the source location of a value.- Specified by:
getSourceLocation
in interfaceFromSourceLocation
- Returns:
- Returns the source location of the value.
-
arrayValue
public static ArrayValue arrayValue(java.util.List<Value> value)
Creates anArrayValue
from a list of values.- Parameters:
value
- the list of values for the array.- Returns:
- returns the created ArrayValue.
-
booleanValue
public static BooleanValue booleanValue(boolean value)
Creates anBooleanValue
from a boolean.- Parameters:
value
- the value for the boolean.- Returns:
- returns the created BooleanValue.
-
emptyValue
public static EmptyValue emptyValue()
Creates anEmptyValue
.- Returns:
- returns the created EmptyValue.
-
endpointValue
public static EndpointValue endpointValue(Node source)
Creates anEndpointValue
from a node.- Parameters:
source
- the node to create an endpoint from.- Returns:
- returns the created EndpointValue.
-
integerValue
public static IntegerValue integerValue(int value)
Creates anIntegerValue
from an integer.- Parameters:
value
- the value for the integer.- Returns:
- returns the created IntegerValue.
-
recordValue
public static RecordValue recordValue(java.util.Map<Identifier,Value> value)
Creates anRecordValue
from a map of identifiers to values.- Parameters:
value
- the map to create a record from.- Returns:
- returns the created RecordValue.
-
stringValue
public static StringValue stringValue(java.lang.String value)
Creates anStringValue
from a string.- Parameters:
value
- the value for the string.- Returns:
- returns the created StringValue.
-
expectArrayValue
public ArrayValue expectArrayValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.- Returns:
- returns an array value.
-
expectBooleanValue
public BooleanValue expectBooleanValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.- Returns:
- returns a boolean value.
-
expectEndpointValue
public EndpointValue expectEndpointValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.- Returns:
- returns an endpoint value
-
expectIntegerValue
public IntegerValue expectIntegerValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.- Returns:
- returns an integer value.
-
expectRecordValue
public RecordValue expectRecordValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.- Returns:
- returns a record value.
-
expectStringValue
public StringValue expectStringValue()
Returns the current value as anArrayValue
, throwingRuntimeException
when the value is the wrong type.- Returns:
- returns a string value.
-
-