Interface JmespathRuntime<T>
- All Superinterfaces:
Comparator<T>
- All Known Implementing Classes:
LiteralExpressionJmespathRuntime
Several methods have default implementations that are at least correct, but implementors can override them with more efficient implementations.
In the documentation of the required behavior of each method, note that conditions like "if the value is NULL", refer to T value where typeOf(value) returns RuntimeType.NULL. A runtime may or may not use a Java `null` value for this purpose.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA builder interface for new ARRAY values.static interfaceA builder interface for new OBJECT values. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new ArrayBuilder.booleanIf the given value is a BOOLEAN, return it as a boolean.asIterable(T value) Iterate over the elements of an ARRAY or the keys of an OBJECT.If the given value is a NUMBER, return it as a Number.If the given value is a STRING, return it as a String.default intcreateBoolean(boolean b) Creates a BOOLEAN value.Returns `null`.createNumber(Number value) Creates a NUMBER value.createString(String string) Creates a STRING value.If the given value is an ARRAY, returns the element at the given index.default booleanReturns true iff the two given values are equal.default booleanis(T value, RuntimeType type) Shorthand fortypeOf(value).equals(type).default booleanReturns true iff the given value is truthy according to the JMESPath specification.intReturns the number of elements in an ARRAY or the number of keys in an OBJECT.numberType(T value) Returns the type of Number that asNumber() will produce for this value.Creates a new ObjectBuilder.default TIf the given value is an ARRAY, returns the specified slice.default StringReturns a JSON string representation of the given value.Returns the basic type of the given value: NULL, BOOLEAN, STRING, NUMBER, OBJECT, or ARRAY.If the given value is an OBJECT, returns the value mapped to the given key.Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
typeOf
Returns the basic type of the given value: NULL, BOOLEAN, STRING, NUMBER, OBJECT, or ARRAY.MUST NOT ever return EXPRESSION or ANY.
-
is
Shorthand fortypeOf(value).equals(type). -
isTruthy
Returns true iff the given value is truthy according to the JMESPath specification. -
equal
Returns true iff the two given values are equal.Note that just calling Objects.equals() is generally not correct because it does not consider different Number representations of the same value the same.
-
compare
- Specified by:
comparein interfaceComparator<T>
-
toString
Returns a JSON string representation of the given value.Note the distinction between this method and asString(), which can be called only on STRINGs and just casts the value to a String.
-
createNull
T createNull()Returns `null`.Runtimes may or may not use a Java null value to represent a JSON null value.
-
createBoolean
Creates a BOOLEAN value. -
asBoolean
If the given value is a BOOLEAN, return it as a boolean. Otherwise, throws a JmespathException of type INVALID_TYPE. -
createString
Creates a STRING value. -
asString
If 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.
-
createNumber
Creates a NUMBER value. -
numberType
Returns the type of Number that asNumber() will produce for this value. Will be more efficient for some runtimes than checking the class of asNumber(). -
asNumber
If the given value is a NUMBER, return it as a Number. Otherwise, throws a JmespathException of type INVALID_TYPE. -
arrayBuilder
JmespathRuntime.ArrayBuilder<T> arrayBuilder()Creates a new ArrayBuilder. -
element
If the given value is an ARRAY, returns the element at the given index. Otherwise, throws a JmespathException of type INVALID_TYPE. -
slice
If the given value is an ARRAY, returns the specified slice. Otherwise, throws a JmespathException of type INVALID_TYPE.Start and stop will always be non-negative, and step will always be non-zero.
-
objectBuilder
JmespathRuntime.ObjectBuilder<T> objectBuilder()Creates a new ObjectBuilder. -
value
If the given value is an OBJECT, returns the value mapped to the given key. Otherwise, returns NULL. -
length
Returns the number of elements in an ARRAY or the number of keys in an OBJECT. Otherwise, throws a JmespathException of type INVALID_TYPE. -
asIterable
Iterate over the elements of an ARRAY or the keys of an OBJECT. Otherwise, throws a JmespathException of type INVALID_TYPE.
-