Class Hierarchy


  • public class Hierarchy
    extends java.lang.Object
    A data structure that represents the entire inheritance hierarchy of the current template and tracks which level in the hierarchy we are currently evaluating.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int current
      Index of the template currently being evaluated.
      private java.util.ArrayList<PebbleTemplateImpl> hierarchy
      A list of all the templates in this hierarchy.
    • Constructor Summary

      Constructors 
      Constructor Description
      Hierarchy​(PebbleTemplateImpl currentTemplate)
      Constructs an inheritance chain with one known template.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void ascend()
      Signifies that the parent template in the hierarchy is now being evaluated so it should be considered the "current" template.
      void descend()
      Signifies that the child template in the hierarchy is now being evaluated so i t should be considered the "current" template.
      PebbleTemplateImpl getChild()
      Returns the child of the template currently being evaluated or null if there is no child.
      PebbleTemplateImpl getParent()
      Returns the parent of the template currently being evaluated or null if there is no parent.
      void pushAncestor​(PebbleTemplateImpl ancestor)
      Adds a known ancestor onto the inheritance chain, does not increment which template is the "current" template being evaluated.
      • Methods inherited from class java.lang.Object

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

      • hierarchy

        private final java.util.ArrayList<PebbleTemplateImpl> hierarchy
        A list of all the templates in this hierarchy. A template at index i is the child to the template at index i+1.
      • current

        private int current
        Index of the template currently being evaluated.
    • Constructor Detail

      • Hierarchy

        public Hierarchy​(PebbleTemplateImpl currentTemplate)
        Constructs an inheritance chain with one known template.
        Parameters:
        currentTemplate - The current template
    • Method Detail

      • pushAncestor

        public void pushAncestor​(PebbleTemplateImpl ancestor)
        Adds a known ancestor onto the inheritance chain, does not increment which template is the "current" template being evaluated.
        Parameters:
        ancestor - The ancestor template
      • ascend

        public void ascend()
        Signifies that the parent template in the hierarchy is now being evaluated so it should be considered the "current" template.
      • descend

        public void descend()
        Signifies that the child template in the hierarchy is now being evaluated so i t should be considered the "current" template.
      • getChild

        public PebbleTemplateImpl getChild()
        Returns the child of the template currently being evaluated or null if there is no child.
        Returns:
        The child template if exists or null
      • getParent

        public PebbleTemplateImpl getParent()
        Returns the parent of the template currently being evaluated or null if there is no parent.
        Returns:
        The parent template if exists or null