Class NodeModel


  • public class NodeModel
    extends java.lang.Object
    Immutable representation of a tree structure accessed through a NodeAdapter.

    A NodeModel instance binds a node with its adapter, providing a uniform way to traverse or compare trees of arbitrary underlying object models.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected NodeAdapter adapter  
      protected java.lang.Object node  
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeModel​(java.lang.Object node, NodeAdapter adapter)
      Creates a new immutable tree with the given root node and adapter.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      NodeAdapter adapter()  
      static java.util.Comparator<java.util.Map.Entry<?,​?>> comparingEntry​(java.util.function.Function<java.util.Map.Entry<?,​?>,​java.lang.Comparable> keyExtractor)  
      static java.util.Comparator<?> comparingNode​(java.util.function.Function<java.lang.Object,​java.lang.Comparable> keyExtractor)  
      (package private) static boolean deepEquals​(java.lang.Object left, NodeAdapter leftAdapter, java.lang.Object right, NodeAdapter rightAdapter)  
      protected static boolean deepEqualsCollection​(java.lang.Iterable<? extends java.lang.Object> left, NodeAdapter leftAdapter, java.lang.Iterable<? extends java.lang.Object> right, NodeAdapter rightAdapter)  
      java.lang.Object node()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • node

        protected final java.lang.Object node
    • Constructor Detail

      • NodeModel

        public NodeModel​(java.lang.Object node,
                         NodeAdapter adapter)
        Creates a new immutable tree with the given root node and adapter.
        Parameters:
        node - the root node of the tree, must not be null
        adapter - the adapter providing access to node types and values, must not be null
        Throws:
        java.lang.NullPointerException - if root or adapter is null
    • Method Detail

      • node

        public java.lang.Object node()
      • deepEquals

        static final boolean deepEquals​(java.lang.Object left,
                                        NodeAdapter leftAdapter,
                                        java.lang.Object right,
                                        NodeAdapter rightAdapter)
      • deepEqualsCollection

        protected static boolean deepEqualsCollection​(java.lang.Iterable<? extends java.lang.Object> left,
                                                      NodeAdapter leftAdapter,
                                                      java.lang.Iterable<? extends java.lang.Object> right,
                                                      NodeAdapter rightAdapter)
      • comparingEntry

        public static java.util.Comparator<java.util.Map.Entry<?,​?>> comparingEntry​(java.util.function.Function<java.util.Map.Entry<?,​?>,​java.lang.Comparable> keyExtractor)
      • comparingNode

        public static java.util.Comparator<?> comparingNode​(java.util.function.Function<java.lang.Object,​java.lang.Comparable> keyExtractor)