Class LiteralExpression
java.lang.Object
software.amazon.smithy.jmespath.JmespathExpression
software.amazon.smithy.jmespath.ast.LiteralExpression
Represents a literal value.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LiteralExpressionSentinel value to represent ANY.static final LiteralExpressionSentinel value to represent any ARRAY.static final LiteralExpressionSentinel value to represent any BOOLEAN.static final LiteralExpressionSentinel value to represent an expression reference.static final LiteralExpressionSentinel value to represent null.static final LiteralExpressionSentinel value to represent any NULL.static final LiteralExpressionSentinel value to represent any OBJECT.static final LiteralExpressionSentinel value to represent any STRING. -
Constructor Summary
ConstructorsConstructorDescriptionLiteralExpression(Object value) LiteralExpression(Object value, int line, int column) -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(ExpressionVisitor<T> visitor) Visits a node using a double-dispatch visitor.booleanGets the value as an array.booleanGets the value as a boolean.Gets the value as a number.Gets the value as an object.Gets the value as a string.static LiteralExpressionCreates 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.inthashCode()booleanhasObjectField(String name) Expects the value to be an object and checks if it contains a field by name.booleanChecks if the value is an array.booleanChecks if the value is a boolean.booleanChecks if the value is null.booleanChecks if the value is a number.booleanChecks if the value is an object.booleanChecks if the value is a string.booleanisTruthy()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:JmespathExpressionVisits a node using a double-dispatch visitor.- Specified by:
acceptin 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 aLiteralExpressionwith 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, aLiteralExpressionwith 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.
-