Class LiteralExpression
- java.lang.Object
- 
- software.amazon.smithy.jmespath.JmespathExpression
- 
- software.amazon.smithy.jmespath.ast.LiteralExpression
 
 
- 
 public final class LiteralExpression extends JmespathExpression Represents a literal value.
- 
- 
Field SummaryFields Modifier and Type Field Description static LiteralExpressionANYSentinel value to represent ANY.static LiteralExpressionARRAYSentinel value to represent any ARRAY.static LiteralExpressionBOOLEANSentinel value to represent any BOOLEAN.static LiteralExpressionEXPREFSentinel value to represent an expression reference.static LiteralExpressionNULLSentinel value to represent null.static LiteralExpressionNUMBERSentinel value to represent any NULL.static LiteralExpressionOBJECTSentinel value to represent any OBJECT.static LiteralExpressionSTRINGSentinel value to represent any STRING.
 - 
Constructor SummaryConstructors Constructor Description LiteralExpression(java.lang.Object value)LiteralExpression(java.lang.Object value, int line, int column)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(ExpressionVisitor<T> visitor)Visits a node using a double-dispatch visitor.booleanequals(java.lang.Object o)java.util.List<java.lang.Object>expectArrayValue()Gets the value as an array.booleanexpectBooleanValue()Gets the value as a boolean.java.lang.NumberexpectNumberValue()Gets the value as a number.java.util.Map<java.lang.String,java.lang.Object>expectObjectValue()Gets the value as an object.java.lang.StringexpectStringValue()Gets the value as a string.static LiteralExpressionfrom(java.lang.Object value)Creates a LiteralExpression fromvalue, unwrapping it if necessary.LiteralExpressiongetArrayIndex(int index)Expects the value to be an array and gets the value at the given index.LiteralExpressiongetObjectField(java.lang.String name)Expects the value to be an object and gets a field by name.RuntimeTypegetType()Gets the type of the value.java.lang.ObjectgetValue()Gets the nullable value contained in the literal value.inthashCode()booleanhasObjectField(java.lang.String name)Expects the value to be an object and checks if it contains a field by name.booleanisArrayValue()Checks if the value is an array.booleanisBooleanValue()Checks if the value is a boolean.booleanisNullValue()Checks if the value is null.booleanisNumberValue()Checks if the value is a number.booleanisObjectValue()Checks if the value is an object.booleanisStringValue()Checks if the value is a string.booleanisTruthy()Returns true if the value is truthy according to JMESPath.java.lang.StringtoString()
 
- 
- 
- 
Field Detail- 
ANYpublic static final LiteralExpression ANY Sentinel value to represent ANY.
 - 
ARRAYpublic static final LiteralExpression ARRAY Sentinel value to represent any ARRAY.
 - 
OBJECTpublic static final LiteralExpression OBJECT Sentinel value to represent any OBJECT.
 - 
BOOLEANpublic static final LiteralExpression BOOLEAN Sentinel value to represent any BOOLEAN.
 - 
STRINGpublic static final LiteralExpression STRING Sentinel value to represent any STRING.
 - 
NUMBERpublic static final LiteralExpression NUMBER Sentinel value to represent any NULL.
 - 
EXPREFpublic static final LiteralExpression EXPREF Sentinel value to represent an expression reference.
 - 
NULLpublic static final LiteralExpression NULL Sentinel value to represent null.
 
- 
 - 
Method Detail- 
frompublic static LiteralExpression from(java.lang.Object value) Creates a LiteralExpression fromvalue, unwrapping it if necessary.- Parameters:
- value- Value to create the expression from.
- Returns:
- Returns the LiteralExpression of the given value.
 
 - 
acceptpublic <T> T accept(ExpressionVisitor<T> visitor) Description copied from class:JmespathExpressionVisits a node using a double-dispatch visitor.- Specified by:
- acceptin class- JmespathExpression
- 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.
 
 - 
getValuepublic java.lang.Object getValue() Gets the nullable value contained in the literal value.- Returns:
- Returns the contained value.
 
 - 
equalspublic boolean equals(java.lang.Object o) - Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
getTypepublic RuntimeType getType() Gets the type of the value.- Returns:
- Returns the literal expression's runtime type.
 
 - 
getObjectFieldpublic LiteralExpression getObjectField(java.lang.String name) 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.
 
 - 
hasObjectFieldpublic boolean hasObjectField(java.lang.String name) 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.
 
 - 
getArrayIndexpublic LiteralExpression getArrayIndex(int index) 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.
 
 - 
isStringValuepublic boolean isStringValue() Checks if the value is a string.- Returns:
- Returns true if the value is a string.
 
 - 
isNumberValuepublic boolean isNumberValue() Checks if the value is a number.- Returns:
- Returns true if the value is a number.
 
 - 
isBooleanValuepublic boolean isBooleanValue() Checks if the value is a boolean.- Returns:
- Returns true if the value is a boolean.
 
 - 
isArrayValuepublic boolean isArrayValue() Checks if the value is an array.- Returns:
- Returns true if the value is an array.
 
 - 
isObjectValuepublic boolean isObjectValue() Checks if the value is an object.- Returns:
- Returns true if the value is an object.
 
 - 
isNullValuepublic boolean isNullValue() Checks if the value is null.- Returns:
- Returns true if the value is null.
 
 - 
expectStringValuepublic java.lang.String expectStringValue() Gets the value as a string.- Returns:
- Returns the string value.
- Throws:
- JmespathException- if the value is not a string.
 
 - 
expectNumberValuepublic java.lang.Number expectNumberValue() Gets the value as a number.- Returns:
- Returns the number value.
- Throws:
- JmespathException- if the value is not a number.
 
 - 
expectBooleanValuepublic boolean expectBooleanValue() Gets the value as a boolean.- Returns:
- Returns the boolean value.
- Throws:
- JmespathException- if the value is not a boolean.
 
 - 
expectArrayValuepublic java.util.List<java.lang.Object> expectArrayValue() Gets the value as an array.- Returns:
- Returns the array value.
- Throws:
- JmespathException- if the value is not an array.
 
 - 
expectObjectValuepublic java.util.Map<java.lang.String,java.lang.Object> expectObjectValue() Gets the value as an object.- Returns:
- Returns the object value.
- Throws:
- JmespathException- if the value is not an object.
 
 - 
isTruthypublic boolean isTruthy() Returns true if the value is truthy according to JMESPath.- Returns:
- Returns true or false if truthy.
 
 
- 
 
-