Package software.amazon.smithy.jmespath
Class LiteralExpressionJmespathRuntime
java.lang.Object
software.amazon.smithy.jmespath.LiteralExpressionJmespathRuntime
- All Implemented Interfaces:
Comparator<LiteralExpression>,JmespathRuntime<LiteralExpression>
public final class LiteralExpressionJmespathRuntime
extends Object
implements JmespathRuntime<LiteralExpression>
A singleton implementation of the JmespathRuntime interface based on instances of the LiteralExpression class.
Does not use values of the additional LiteralExpression.EXPREF or LiteralExpression.ANY types as they aren't necessary.
-
Nested Class Summary
Nested classes/interfaces inherited from interface software.amazon.smithy.jmespath.evaluation.JmespathRuntime
JmespathRuntime.ArrayBuilder<T>, JmespathRuntime.ObjectBuilder<T> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a new ArrayBuilder.booleanasBoolean(LiteralExpression value) If the given value is a BOOLEAN, return it as a boolean.asIterable(LiteralExpression array) Iterate over the elements of an ARRAY or the keys of an OBJECT.asNumber(LiteralExpression value) If the given value is a NUMBER, return it as a Number.asString(LiteralExpression value) If the given value is a STRING, return it as a String.createBoolean(boolean b) Creates a BOOLEAN value.Returns `null`.createNumber(Number value) Creates a NUMBER value.createString(String string) Creates a STRING value.element(LiteralExpression array, int index) If the given value is an ARRAY, returns the element at the given index.intlength(LiteralExpression value) Returns the number of elements in an ARRAY or the number of keys in an OBJECT.numberType(LiteralExpression value) Returns the type of Number that asNumber() will produce for this value.Creates a new ObjectBuilder.typeOf(LiteralExpression value) Returns the basic type of the given value: NULL, BOOLEAN, STRING, NUMBER, OBJECT, or ARRAY.value(LiteralExpression value, LiteralExpression name) If the given value is an OBJECT, returns the value mapped to the given key.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
LiteralExpressionJmespathRuntime
public LiteralExpressionJmespathRuntime()
-
-
Method Details
-
typeOf
Description copied from interface:JmespathRuntimeReturns the basic type of the given value: NULL, BOOLEAN, STRING, NUMBER, OBJECT, or ARRAY.MUST NOT ever return EXPRESSION or ANY.
- Specified by:
typeOfin interfaceJmespathRuntime<LiteralExpression>
-
createNull
Description copied from interface:JmespathRuntimeReturns `null`.Runtimes may or may not use a Java null value to represent a JSON null value.
- Specified by:
createNullin interfaceJmespathRuntime<LiteralExpression>
-
createBoolean
Description copied from interface:JmespathRuntimeCreates a BOOLEAN value.- Specified by:
createBooleanin interfaceJmespathRuntime<LiteralExpression>
-
asBoolean
Description copied from interface:JmespathRuntimeIf the given value is a BOOLEAN, return it as a boolean. Otherwise, throws a JmespathException of type INVALID_TYPE.- Specified by:
asBooleanin interfaceJmespathRuntime<LiteralExpression>
-
createString
Description copied from interface:JmespathRuntimeCreates a STRING value.- Specified by:
createStringin interfaceJmespathRuntime<LiteralExpression>
-
asString
Description copied from interface:JmespathRuntimeIf the given value is a STRING, return it as a String. Otherwise, throws a JmespathException of type INVALID_TYPE.Note the distinction between this method and toString(), which can be called on any value and produces a JSON string.
- Specified by:
asStringin interfaceJmespathRuntime<LiteralExpression>
-
createNumber
Description copied from interface:JmespathRuntimeCreates a NUMBER value.- Specified by:
createNumberin interfaceJmespathRuntime<LiteralExpression>
-
numberType
Description copied from interface:JmespathRuntimeReturns the type of Number that asNumber() will produce for this value. Will be more efficient for some runtimes than checking the class of asNumber().- Specified by:
numberTypein interfaceJmespathRuntime<LiteralExpression>
-
asNumber
Description copied from interface:JmespathRuntimeIf the given value is a NUMBER, return it as a Number. Otherwise, throws a JmespathException of type INVALID_TYPE.- Specified by:
asNumberin interfaceJmespathRuntime<LiteralExpression>
-
length
Description copied from interface:JmespathRuntimeReturns the number of elements in an ARRAY or the number of keys in an OBJECT. Otherwise, throws a JmespathException of type INVALID_TYPE.- Specified by:
lengthin interfaceJmespathRuntime<LiteralExpression>
-
element
Description copied from interface:JmespathRuntimeIf the given value is an ARRAY, returns the element at the given index. Otherwise, throws a JmespathException of type INVALID_TYPE.- Specified by:
elementin interfaceJmespathRuntime<LiteralExpression>
-
asIterable
Description copied from interface:JmespathRuntimeIterate over the elements of an ARRAY or the keys of an OBJECT. Otherwise, throws a JmespathException of type INVALID_TYPE.- Specified by:
asIterablein interfaceJmespathRuntime<LiteralExpression>
-
arrayBuilder
Description copied from interface:JmespathRuntimeCreates a new ArrayBuilder.- Specified by:
arrayBuilderin interfaceJmespathRuntime<LiteralExpression>
-
value
Description copied from interface:JmespathRuntimeIf the given value is an OBJECT, returns the value mapped to the given key. Otherwise, returns NULL.- Specified by:
valuein interfaceJmespathRuntime<LiteralExpression>
-
objectBuilder
Description copied from interface:JmespathRuntimeCreates a new ObjectBuilder.- Specified by:
objectBuilderin interfaceJmespathRuntime<LiteralExpression>
-