Class Element

  • All Implemented Interfaces:
    Tree, java.lang.Comparable<Tree>

    class Element
    extends java.lang.Object
    implements Tree
    An element can be compared to another element of the same type. Elements with the same name and same place in the hierarchy should have the same type. The idea is that for a certain resource type you create an element (Structured or Leaf). This process is done for the newer and older resource.

    A Leaf type has a value, comparison is rather simple in this case.

    A Structured type has named children. The comparison between the newer and older child elements is then done on their name. Two elements with the same name are then matched.

    The classes are prepared for extension but so far it turned out to be unnecessary.

    • Field Detail

      • EMPTY

        static final Element[] EMPTY
      • type

        final Type type
      • name

        final java.lang.String name
      • remove

        final Delta remove
      • comment

        final java.lang.String comment
      • children

        final Element[] children
    • Constructor Detail

      • Element

        Element​(Type type,
                java.lang.String name)
      • Element

        Element​(Type type,
                java.lang.String name,
                Element... children)
      • Element

        Element​(Type type,
                java.lang.String name,
                java.util.Collection<? extends Element> children,
                Delta add,
                Delta remove,
                java.lang.String comment)
      • Element

        public Element​(Tree.Data data)
    • Method Detail

      • getType

        public Type getType()
        Specified by:
        getType in interface Tree
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface Tree
      • getComment

        java.lang.String getComment()
      • compareTo

        public int compareTo​(Tree other)
        Specified by:
        compareTo in interface java.lang.Comparable<Tree>
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • diff

        public Diff diff​(Tree older)
        Specified by:
        diff in interface Tree
      • get

        public Element get​(java.lang.String name)
        Specified by:
        get in interface Tree
      • toString

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

        private void toString​(java.lang.StringBuilder sb,
                              java.lang.String indent)