Class SourceMapField

java.lang.Object
org.elasticsearch.script.field.SourceMapField
All Implemented Interfaces:
Iterable<Object>, Field<Object>
Direct Known Subclasses:
WriteField

public class SourceMapField extends Object implements Field<Object>
Provides an immutable view of a field in a source map.
  • Field Details

  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Get the path represented by this Field
      Specified by:
      getName in interface Field<Object>
    • exists

      public boolean exists()
      Does the path exist?
    • isEmpty

      public boolean isEmpty()
      Is this path associated with any values?
      Specified by:
      isEmpty in interface Field<Object>
    • size

      public int size()
      How many elements are at the leaf of this path?
      Specified by:
      size in interface Field<Object>
    • iterator

      public Iterator<Object> iterator()
      Iterate through all elements of this path with an iterator that cannot mutate the underlying map.
      Specified by:
      iterator in interface Iterable<Object>
    • getListIterator

      protected Iterator<Object> getListIterator(List<?> list)
      Get an iterator for the given list that cannot mutate the underlying list. Subclasses can override this method to allow for mutating iterators.
      Parameters:
      list - the list to get an iterator for
      Returns:
      an iterator that cannot mutate the underlying list
    • get

      public Object get(Object defaultValue)
      Get the value at this path, if there is no value then get the provided
    • get

      public Object get(int index, Object defaultValue)
      Get the value at the given index at this path or if there is no such value.
    • hasValue

      public boolean hasValue(Predicate<Object> predicate)
      Is there any value matching at this path?
    • setPath

      protected void setPath(String path)
      Change the path and clear the existing resolution by setting leaf and container to null. Caller needs to re-resolve after this call.
    • resolveDepthFlat

      protected final void resolveDepthFlat()
      Resolve path from the root. Tries to resolve the path one segment at a time, if the segment is not mapped to a Java Map, then treats that segment and the rest as the leaf if it resolves. a.b.c could be resolved as I) ['a']['b']['c'] if 'a' is a Map at the root and 'b' is a Map in 'a', 'c' need not exist in 'b'. II) ['a']['b.c'] if 'a' is a Map at the root and 'b' does not exist in 'a's Map but 'b.c' does. III) ['a.b.c'] if 'a' doesn't exist at the root but 'a.b.c' does. container and leaf and non-null if resolved.