Interface CommerceEntryGroupUtils
-
- All Known Implementing Classes:
DefaultCommerceEntryGroupUtils
public interface CommerceEntryGroupUtilsManipulation withEntryGroupData.- See Also:
EntryGroupService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intfindMaxGroupNumber(java.util.List<EntryGroupData> roots)Returns max value ofEntryGroupData#groupNumber.EntryGroupDatagetGroup(AbstractOrderData order, java.lang.Integer groupNumber)ReturnsEntryGroupDataby groupNumber from given orderEntryGroupDatagetGroup(AbstractOrderData order, java.util.Collection<java.lang.Integer> groupNumbers, GroupType groupType)Searches for entry group which is a type ofgroupTypeand which number belongs to thegroupNumbers.java.util.List<EntryGroupData>getLeaves(EntryGroupData root)Returns all leaf nodes of group tree, preventing their natural order.java.util.List<EntryGroupData>getNestedGroups(EntryGroupData root)Flatten group tree and return it as a plain list of groups.
-
-
-
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- ifrootis null
-
getGroup
@Nonnull EntryGroupData getGroup(@Nonnull AbstractOrderData order, @Nonnull java.lang.Integer groupNumber)
ReturnsEntryGroupDataby groupNumber from given order- Parameters:
groupNumber- number of the group to search fororder- order containing entry group trees- Returns:
EntryGroupDatawith given groupNumber from the order- Throws:
java.lang.IllegalArgumentException- if no group with given groupNumber in the orderjava.lang.IllegalArgumentException- iforderis nulljava.lang.IllegalArgumentException- iforder.rootGroupsis nulljava.lang.IllegalArgumentException- ifgroupNumberis 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 ofgroupTypeand which number belongs to thegroupNumbers.- Parameters:
order- order what is expected to contain the desired groupgroupNumbers- possible group numbers. Usually are taken fromOrderEntryData.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 ofEntryGroupData#groupNumber.- Parameters:
roots- root groups- Returns:
- maximum group number among the whole forest
-
-