Class Cursor


  • public class Cursor
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Cursor​(@Nullable Cursor parent, java.lang.Object value)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T computeMessageIfAbsent​(java.lang.String key, java.util.function.Function<java.lang.String,​? extends T> mappingFunction)  
      Cursor dropParentUntil​(java.util.function.Predicate<java.lang.Object> valuePredicate)  
      Cursor dropParentWhile​(java.util.function.Predicate<java.lang.Object> valuePredicate)  
      <T> T firstEnclosing​(java.lang.Class<T> tClass)  
      <T> T firstEnclosingOrThrow​(java.lang.Class<T> tClass)  
      Cursor fork()
      Creates a cursor at the same position, but with its own messages that can't influence the messages of the cursor that was forked.
      <T> T getMessage​(java.lang.String key)
      Finds the closest message matching the provided key, leaving it in the message map for further access.
      <T> T getMessage​(java.lang.String key, T defaultValue)  
      <T> T getNearestMessage​(java.lang.String key)
      Finds the closest message matching the provided key, leaving it in the message map for further access.
      <T> T getNearestMessage​(java.lang.String key, T defaultValue)  
      @Nullable Cursor getParent()  
      @Nullable Cursor getParent​(int levels)  
      Cursor getParentOrThrow()  
      Cursor getParentOrThrow​(int levels)  
      java.util.Iterator<java.lang.Object> getPath()  
      java.util.Iterator<java.lang.Object> getPath​(java.util.function.Predicate<java.lang.Object> filter)  
      java.util.stream.Stream<java.lang.Object> getPathAsStream()  
      java.util.stream.Stream<java.lang.Object> getPathAsStream​(java.util.function.Predicate<java.lang.Object> filter)  
      Cursor getRoot()  
      <T> T getValue()  
      boolean isScopeInPath​(Tree scope)  
      <T> T pollMessage​(java.lang.String key)
      Finds the message matching the provided key, removing it from the message map.
      <T> T pollNearestMessage​(java.lang.String key)
      Finds the closest message matching the provided key, removing it from the message map.
      void putMessage​(java.lang.String key, java.lang.Object value)  
      void putMessageOnFirstEnclosing​(java.lang.Class<?> enclosing, java.lang.String key, java.lang.Object value)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getRoot

        public Cursor getRoot()
      • getPath

        public java.util.Iterator<java.lang.Object> getPath()
      • getPath

        public java.util.Iterator<java.lang.Object> getPath​(java.util.function.Predicate<java.lang.Object> filter)
      • getPathAsStream

        public java.util.stream.Stream<java.lang.Object> getPathAsStream()
      • getPathAsStream

        public java.util.stream.Stream<java.lang.Object> getPathAsStream​(java.util.function.Predicate<java.lang.Object> filter)
      • firstEnclosing

        @Nullable
        public <T> T firstEnclosing​(java.lang.Class<T> tClass)
      • firstEnclosingOrThrow

        public <T> T firstEnclosingOrThrow​(java.lang.Class<T> tClass)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • dropParentUntil

        public Cursor dropParentUntil​(java.util.function.Predicate<java.lang.Object> valuePredicate)
      • dropParentWhile

        public Cursor dropParentWhile​(java.util.function.Predicate<java.lang.Object> valuePredicate)
      • getParentOrThrow

        public Cursor getParentOrThrow()
      • getValue

        public <T> T getValue()
      • isScopeInPath

        public boolean isScopeInPath​(Tree scope)
      • putMessageOnFirstEnclosing

        public void putMessageOnFirstEnclosing​(java.lang.Class<?> enclosing,
                                               java.lang.String key,
                                               java.lang.Object value)
      • putMessage

        public void putMessage​(java.lang.String key,
                               java.lang.Object value)
      • computeMessageIfAbsent

        public <T> T computeMessageIfAbsent​(java.lang.String key,
                                            java.util.function.Function<java.lang.String,​? extends T> mappingFunction)
      • getNearestMessage

        @Nullable
        public <T> T getNearestMessage​(java.lang.String key)
        Finds the closest message matching the provided key, leaving it in the message map for further access.
        Type Parameters:
        T - The expected value of the message.
        Parameters:
        key - The message key to find.
        Returns:
        The closest message matching the provided key in the cursor stack, or null if none.
      • getNearestMessage

        public <T> T getNearestMessage​(java.lang.String key,
                                       T defaultValue)
      • pollNearestMessage

        @Nullable
        public <T> T pollNearestMessage​(java.lang.String key)
        Finds the closest message matching the provided key, removing it from the message map.
        Type Parameters:
        T - The expected value of the message.
        Parameters:
        key - The message key to find.
        Returns:
        The closest message matching the provided key in the cursor stack, or null if none.
      • getMessage

        @Nullable
        public <T> T getMessage​(java.lang.String key)
        Finds the closest message matching the provided key, leaving it in the message map for further access.
        Type Parameters:
        T - The expected value of the message.
        Parameters:
        key - The message key to find.
        Returns:
        The message matching the provided key, or null if none.
      • getMessage

        public <T> T getMessage​(java.lang.String key,
                                T defaultValue)
      • pollMessage

        @Nullable
        public <T> T pollMessage​(java.lang.String key)
        Finds the message matching the provided key, removing it from the message map.
        Type Parameters:
        T - The expected value of the message.
        Parameters:
        key - The message key to find.
        Returns:
        The message matching the provided key, or null if none.
      • fork

        public Cursor fork()
        Creates a cursor at the same position, but with its own messages that can't influence the messages of the cursor that was forked.
        Returns:
        A new cursor with the same position but an initially clear set of messages.