Class RMGroup

  • All Implemented Interfaces:
    RMKey.Get, RMKeyChain.Get, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess
    Direct Known Subclasses:
    RMGroup.Running

    public class RMGroup
    extends java.util.ArrayList
    implements RMKey.Get, RMKeyChain.Get
    This class is a smart List subclass used to hold objects from an original list broken down by grouping keys.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  RMGroup.Running
      This RMGroup subclass/inner-class represents a subset of a group up to the given endGroup.
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      RMGroup()
      Creates an empty group.
      RMGroup​(java.util.List aList)
      Creates a group with the (assumed) list of groups.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      RMGroup clone()
      Standard clone implementation.
      RMGroup cloneDeep()
      Clone deep implementation - clones this group and any child groups.
      RMGroup cloneEmpty()
      Clone deep implementation - clones this group and any child groups.
      boolean equals​(java.lang.Object anObj)
      Standard equals.
      java.util.List getAllValues​(java.lang.String aKey)
      Returns all values for a given grouping in this group hierarchy.
      RMGroup getGroup​(int anIndex)
      Returns the sub-group at the given index.
      RMGroup getGroupLast()
      Returns the last sub-group.
      java.lang.String getKey()
      Returns the key associated with this group.
      static java.lang.String getKey​(java.util.List aList)
      Returns the key for the given List if it is an RMGroup instance.
      java.lang.Object getKeyChainValue​(java.lang.Object aRoot, RMKeyChain aKeyChain)
      Custom implementation of valueForKeyChain to handle top N groups.
      java.lang.Object getKeyValue​(java.lang.String aKey)
      Custom implementation of valueForKey to handle group heritage keys.
      RMGroup getNextPeer()
      Returns the next group which is a peer to this one.
      RMGroup getPageEndGroup()
      Returns the child group for the most recent page end.
      RMGroup getPageStartGroup()
      Returns the child group for the most recent page start.
      RMGroup getParent()
      Returns the parent for this group.
      int getParentCount()
      Returns the number of parents that this group has.
      java.lang.Object getValue()
      Returns the value associated with this group.
      void groupBy​(RMGrouper aGrouper, int start)
      Groups this group by the groupings in the given grouper.
      void groupBy​(RMGrouping aGrouping)
      Groups this group by given grouping.
      void groupBy​(RMGrouping aGrouping, java.util.List aValuesList)
      Groups this group by given grouping.
      void groupByKey​(java.lang.String aKey, java.util.List aValuesList)
      Groups a new group by given keys list.
      void groupByLeafKey​(java.lang.String aKey)
      Turns all list objects into leaf groups.
      int index()
      Returns the index of this group in its parent.
      boolean isAncestor​(RMGroup aGroup)
      Returns whether given group is an ancestor group.
      boolean isLeaf()
      Returns whether this group is a leaf group.
      static boolean isLeaf​(java.util.List aList)
      Returns whether the given List is an RMGroup instance that also isLeaf.
      boolean isTopNOthers()
      Returns whether this group is made up of the remainders from a TopN sort.
      void setPageEndGroup​(RMGroup aGroup)
      Sets the child group for the most recent page end.
      void setPageStartGroup​(RMGroup aGroup)
      Sets the child group for the most recent page start.
      void setParent​(RMGroup aGroup)
      Sets the parent for this group.
      void setTopNOthers​(boolean aFlag)
      Sets whether this group is made up of the remainders from a TopN sort.
      void sortBy​(RMGrouping aGrouping)
      Sorts by sorts in given grouping.
      void sortBy​(java.util.List aSortList)
      Sorts the group by the sorts in the given list.
      RMGroup subgroup​(int start, int end)
      Returns a subset of this group from start index, inclusive, to end index, exclusive.
      RMGroup subgroup​(RMGroup startGroup, RMGroup endGroup)
      Returns a subset of this group, running deep, which only includes the subset of the tree starting at startGroup and ending at (but not including) endGroup.
      void topNSortBy​(RMTopNSort aSort)
      Performs top N sort on group for an individual sort.
      java.lang.String toString()
      Returns a string representation of this group.
      • Methods inherited from class java.util.ArrayList

        add, add, addAll, addAll, clear, contains, ensureCapacity, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractCollection

        containsAll
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.util.List

        containsAll
    • Constructor Detail

      • RMGroup

        public RMGroup()
        Creates an empty group.
      • RMGroup

        public RMGroup​(java.util.List aList)
        Creates a group with the (assumed) list of groups.
    • Method Detail

      • getKey

        public java.lang.String getKey()
        Returns the key associated with this group.
      • getValue

        public java.lang.Object getValue()
        Returns the value associated with this group.
      • getParent

        public RMGroup getParent()
        Returns the parent for this group.
      • setParent

        public void setParent​(RMGroup aGroup)
        Sets the parent for this group.
      • getParentCount

        public int getParentCount()
        Returns the number of parents that this group has.
      • isAncestor

        public boolean isAncestor​(RMGroup aGroup)
        Returns whether given group is an ancestor group.
      • isLeaf

        public boolean isLeaf()
        Returns whether this group is a leaf group.
      • isTopNOthers

        public boolean isTopNOthers()
        Returns whether this group is made up of the remainders from a TopN sort.
      • setTopNOthers

        public void setTopNOthers​(boolean aFlag)
        Sets whether this group is made up of the remainders from a TopN sort.
      • getPageStartGroup

        public RMGroup getPageStartGroup()
        Returns the child group for the most recent page start.
      • setPageStartGroup

        public void setPageStartGroup​(RMGroup aGroup)
        Sets the child group for the most recent page start.
      • getPageEndGroup

        public RMGroup getPageEndGroup()
        Returns the child group for the most recent page end.
      • setPageEndGroup

        public void setPageEndGroup​(RMGroup aGroup)
        Sets the child group for the most recent page end.
      • index

        public int index()
        Returns the index of this group in its parent.
      • getGroup

        public RMGroup getGroup​(int anIndex)
        Returns the sub-group at the given index.
      • getGroupLast

        public RMGroup getGroupLast()
        Returns the last sub-group.
      • groupBy

        public void groupBy​(RMGrouper aGrouper,
                            int start)
        Groups this group by the groupings in the given grouper.
      • groupBy

        public void groupBy​(RMGrouping aGrouping)
        Groups this group by given grouping.
      • groupBy

        public void groupBy​(RMGrouping aGrouping,
                            java.util.List aValuesList)
        Groups this group by given grouping.
      • groupByKey

        public void groupByKey​(java.lang.String aKey,
                               java.util.List aValuesList)
        Groups a new group by given keys list.
      • groupByLeafKey

        public void groupByLeafKey​(java.lang.String aKey)
        Turns all list objects into leaf groups.
      • topNSortBy

        public void topNSortBy​(RMTopNSort aSort)
        Performs top N sort on group for an individual sort.
      • sortBy

        public void sortBy​(RMGrouping aGrouping)
        Sorts by sorts in given grouping.
      • sortBy

        public void sortBy​(java.util.List aSortList)
        Sorts the group by the sorts in the given list.
      • getAllValues

        public java.util.List getAllValues​(java.lang.String aKey)
        Returns all values for a given grouping in this group hierarchy.
      • subgroup

        public RMGroup subgroup​(int start,
                                int end)
        Returns a subset of this group from start index, inclusive, to end index, exclusive.
      • subgroup

        public RMGroup subgroup​(RMGroup startGroup,
                                RMGroup endGroup)
        Returns a subset of this group, running deep, which only includes the subset of the tree starting at startGroup and ending at (but not including) endGroup.
      • getKey

        public static java.lang.String getKey​(java.util.List aList)
        Returns the key for the given List if it is an RMGroup instance.
      • isLeaf

        public static boolean isLeaf​(java.util.List aList)
        Returns whether the given List is an RMGroup instance that also isLeaf.
      • getKeyValue

        public java.lang.Object getKeyValue​(java.lang.String aKey)
        Custom implementation of valueForKey to handle group heritage keys.
        Specified by:
        getKeyValue in interface RMKey.Get
      • getKeyChainValue

        public java.lang.Object getKeyChainValue​(java.lang.Object aRoot,
                                                 RMKeyChain aKeyChain)
        Custom implementation of valueForKeyChain to handle top N groups.
        Specified by:
        getKeyChainValue in interface RMKeyChain.Get
      • getNextPeer

        public RMGroup getNextPeer()
        Returns the next group which is a peer to this one.
      • equals

        public boolean equals​(java.lang.Object anObj)
        Standard equals. Just check identity because leaf objects might be interconnected (and can stack overflow).
        Specified by:
        equals in interface java.util.Collection
        Specified by:
        equals in interface java.util.List
        Overrides:
        equals in class java.util.ArrayList
      • clone

        public RMGroup clone()
        Standard clone implementation.
        Overrides:
        clone in class java.util.ArrayList
      • cloneDeep

        public RMGroup cloneDeep()
        Clone deep implementation - clones this group and any child groups.
      • cloneEmpty

        public RMGroup cloneEmpty()
        Clone deep implementation - clones this group and any child groups.
      • toString

        public java.lang.String toString()
        Returns a string representation of this group.
        Overrides:
        toString in class java.util.AbstractCollection