Interface ElementExtractor<T>

Type Parameters:
T - the representation's element type: the common supertype of its map, array, and primitive elements.
All Known Implementing Classes:
DocumentElementExtractor, JsonObjectElementExtractor, MapElementExtractor, PyDictionaryElementExtractor

public interface ElementExtractor<T>
Navigates one concrete document-like representation (JSON, Document, Python dictionary, plain Java maps, etc.) on behalf of ElementPathEvaluator, which walks a parsed path one element at a time: extractKey(T, java.lang.String) steps into map elements, extractIndex(T, int) steps into array elements, and isPrimitive(T)/toJava(T) convert the final element to a plain Java value.
  • Method Details

    • isMap

      boolean isMap(@Nullable T element)
      Returns:
      true if element is a map: a container extractKey(T, java.lang.String) can step into; false for null.
    • extractKey

      @Nullable T extractKey(T element, String key)
      Returns:
      the value at key; null if the key is present with a null value.
      Throws:
      ElementExtractor.ElementNotFoundException - if element has no value at key.
    • mapName

      String mapName()
      Returns:
      the representation's name for its map type (e.g. "JsonObject"), used in type-mismatch error messages.
    • isArray

      boolean isArray(@Nullable T element)
      Returns:
      true if element is an array: a container extractIndex(T, int) can step into; false for null.
    • extractIndex

      @Nullable T extractIndex(T element, int index)
      Returns:
      the value at index; null if the slot holds a null value.
      Throws:
      ElementExtractor.ElementNotFoundException - if index is out of range for element.
    • arraySize

      int arraySize(T element)
      Returns:
      the number of elements in element, for which isArray(T) is true.
    • arrayName

      String arrayName()
      Returns:
      the representation's name for its array type (e.g. "JsonArray"), used in type-mismatch and out-of-bounds error messages.
    • isNull

      boolean isNull(@Nullable T element)
      Returns:
      true if element is a Java null or the representation's own null element (e.g. JsonNull).
    • isPrimitive

      boolean isPrimitive(@Nullable T element)
      Returns:
      true if element is a leaf value — null or a primitive — that toJava(T) converts to a plain Java value; false if it is a map or array, which the evaluator returns in its native representation.
    • toJava

      Object toJava(T element)
      Returns:
      the plain Java equivalent (e.g. String, Long, Double, Boolean) of an element for which isPrimitive(T) is true; null for the representation's null element.