Interface CommerceEntryGroupUtils

    • Method Detail

      • getNestedGroups

        @Nonnull
        java.util.List<EntryGroupData> getNestedGroups​(@Nonnull
                                                       EntryGroupData root)
        Flatten group tree and return it as a plain list of groups.

        The method keeps item order unchanged: first goes root item, then its first child, then the children of that child and so forth.

        Parameters:
        root - node to start collecting from
        Returns:
        list, that includes the node and all its descendants
        Throws:
        java.lang.IllegalArgumentException - is root is null
      • getLeaves

        @Nonnull
        java.util.List<EntryGroupData> getLeaves​(@Nonnull
                                                 EntryGroupData root)
        Returns all leaf nodes of group tree, preventing their natural order.
        Parameters:
        root - root node of group tree
        Returns:
        leaf nodes
        Throws:
        java.lang.IllegalArgumentException - if root is null
      • getGroup

        @Nonnull
        EntryGroupData getGroup​(@Nonnull
                                AbstractOrderData order,
                                @Nonnull
                                java.lang.Integer groupNumber)
        Returns EntryGroupData by groupNumber from given order
        Parameters:
        groupNumber - number of the group to search for
        order - order containing entry group trees
        Returns:
        EntryGroupData with given groupNumber from the order
        Throws:
        java.lang.IllegalArgumentException - if no group with given groupNumber in the order
        java.lang.IllegalArgumentException - if order is null
        java.lang.IllegalArgumentException - if order.rootGroups is null
        java.lang.IllegalArgumentException - if groupNumber is null
      • getGroup

        @Nonnull
        EntryGroupData getGroup​(@Nonnull
                                AbstractOrderData order,
                                @Nonnull
                                java.util.Collection<java.lang.Integer> groupNumbers,
                                @Nonnull
                                GroupType groupType)
        Searches for entry group which is a type of groupType and which number belongs to the groupNumbers.
        Parameters:
        order - order what is expected to contain the desired group
        groupNumbers - possible group numbers. Usually are taken from OrderEntryData.getEntryGroupNumbers()
        groupType - desired group type
        Returns:
        group
        Throws:
        java.lang.IllegalArgumentException - if group was not found or any of the args is invalid
      • findMaxGroupNumber

        int findMaxGroupNumber​(java.util.List<EntryGroupData> roots)
        Returns max value of EntryGroupData#groupNumber.
        Parameters:
        roots - root groups
        Returns:
        maximum group number among the whole forest