Class LiteralExpression
java.lang.Object
software.amazon.smithy.jmespath.JmespathExpression
software.amazon.smithy.jmespath.ast.LiteralExpression
Represents a literal value.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final LiteralExpression
Sentinel value to represent ANY.static final LiteralExpression
Sentinel value to represent any ARRAY.static final LiteralExpression
Sentinel value to represent any BOOLEAN.static final LiteralExpression
Sentinel value to represent an expression reference.static final LiteralExpression
Sentinel value to represent null.static final LiteralExpression
Sentinel value to represent any NULL.static final LiteralExpression
Sentinel value to represent any OBJECT.static final LiteralExpression
Sentinel value to represent any STRING. -
Constructor Summary
ConstructorDescriptionLiteralExpression
(Object value) LiteralExpression
(Object value, int line, int column) -
Method Summary
Modifier and TypeMethodDescription<T> T
accept
(ExpressionVisitor<T> visitor) Visits a node using a double-dispatch visitor.boolean
Gets the value as an array.boolean
Gets the value as a boolean.Gets the value as a number.Gets the value as an object.Gets the value as a string.static LiteralExpression
Creates a LiteralExpression fromvalue
, unwrapping it if necessary.getArrayIndex
(int index) Expects the value to be an array and gets the value at the given index.getObjectField
(String name) Expects the value to be an object and gets a field by name.getType()
Gets the type of the value.getValue()
Gets the nullable value contained in the literal value.int
hashCode()
boolean
hasObjectField
(String name) Expects the value to be an object and checks if it contains a field by name.boolean
Checks if the value is an array.boolean
Checks if the value is a boolean.boolean
Checks if the value is null.boolean
Checks if the value is a number.boolean
Checks if the value is an object.boolean
Checks if the value is a string.boolean
isTruthy()
Returns true if the value is truthy according to JMESPath.toString()
-
Field Details
-
ANY
Sentinel value to represent ANY. -
ARRAY
Sentinel value to represent any ARRAY. -
OBJECT
Sentinel value to represent any OBJECT. -
BOOLEAN
Sentinel value to represent any BOOLEAN. -
STRING
Sentinel value to represent any STRING. -
NUMBER
Sentinel value to represent any NULL. -
EXPREF
Sentinel value to represent an expression reference. -
NULL
Sentinel value to represent null.
-
-
Constructor Details
-
LiteralExpression
-
LiteralExpression
-
-
Method Details
-
from
Creates a LiteralExpression fromvalue
, unwrapping it if necessary.- Parameters:
value
- Value to create the expression from.- Returns:
- Returns the LiteralExpression of the given
value
.
-
accept
Description copied from class:JmespathExpression
Visits a node using a double-dispatch visitor.- Specified by:
accept
in classJmespathExpression
- Type Parameters:
T
- Type of value the visitor returns.- Parameters:
visitor
- Visitor to accept on the node.- Returns:
- Returns the result of applying the visitor.
-
getValue
Gets the nullable value contained in the literal value.- Returns:
- Returns the contained value.
-
equals
-
hashCode
public int hashCode() -
toString
-
getType
Gets the type of the value.- Returns:
- Returns the literal expression's runtime type.
-
getObjectField
Expects the value to be an object and gets a field by name. If the field does not exist, then aLiteralExpression
with a null value is returned.- Parameters:
name
- Field to get from the expected object.- Returns:
- Returns the object field value.
-
hasObjectField
Expects the value to be an object and checks if it contains a field by name.- Parameters:
name
- Field to get from the expected object.- Returns:
- Returns true if the object contains the given key.
-
getArrayIndex
Expects the value to be an array and gets the value at the given index. If the index is negative, it is computed to the array length minus the index. If the computed index does not exist, aLiteralExpression
with a null value is returned.- Parameters:
index
- Index to get from the array.- Returns:
- Returns the array value.
-
isStringValue
public boolean isStringValue()Checks if the value is a string.- Returns:
- Returns true if the value is a string.
-
isNumberValue
public boolean isNumberValue()Checks if the value is a number.- Returns:
- Returns true if the value is a number.
-
isBooleanValue
public boolean isBooleanValue()Checks if the value is a boolean.- Returns:
- Returns true if the value is a boolean.
-
isArrayValue
public boolean isArrayValue()Checks if the value is an array.- Returns:
- Returns true if the value is an array.
-
isObjectValue
public boolean isObjectValue()Checks if the value is an object.- Returns:
- Returns true if the value is an object.
-
isNullValue
public boolean isNullValue()Checks if the value is null.- Returns:
- Returns true if the value is null.
-
expectStringValue
Gets the value as a string.- Returns:
- Returns the string value.
- Throws:
JmespathException
- if the value is not a string.
-
expectNumberValue
Gets the value as a number.- Returns:
- Returns the number value.
- Throws:
JmespathException
- if the value is not a number.
-
expectBooleanValue
public boolean expectBooleanValue()Gets the value as a boolean.- Returns:
- Returns the boolean value.
- Throws:
JmespathException
- if the value is not a boolean.
-
expectArrayValue
Gets the value as an array.- Returns:
- Returns the array value.
- Throws:
JmespathException
- if the value is not an array.
-
expectObjectValue
Gets the value as an object.- Returns:
- Returns the object value.
- Throws:
JmespathException
- if the value is not an object.
-
isTruthy
public boolean isTruthy()Returns true if the value is truthy according to JMESPath.- Returns:
- Returns true or false if truthy.
-