Interface CommerceEntryGroupUtils
- All Known Implementing Classes:
DefaultCommerceEntryGroupUtils
public interface CommerceEntryGroupUtils
Manipulation with
EntryGroupData.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionintfindMaxGroupNumber(List<EntryGroupData> roots) Returns max value ofEntryGroupData#groupNumber.getGroup(AbstractOrderData order, Integer groupNumber) ReturnsEntryGroupDataby groupNumber from given ordergetGroup(AbstractOrderData order, Collection<Integer> groupNumbers, GroupType groupType) Searches for entry group which is a type ofgroupTypeand which number belongs to thegroupNumbers.getLeaves(EntryGroupData root) Returns all leaf nodes of group tree, preventing their natural order.Flatten group tree and return it as a plain list of groups.
-
Method Details
-
getNestedGroups
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:
IllegalArgumentException- is root is null
-
getLeaves
Returns all leaf nodes of group tree, preventing their natural order.- Parameters:
root- root node of group tree- Returns:
- leaf nodes
- Throws:
IllegalArgumentException- ifrootis null
-
getGroup
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:
IllegalArgumentException- if no group with given groupNumber in the orderIllegalArgumentException- iforderis nullIllegalArgumentException- iforder.rootGroupsis nullIllegalArgumentException- ifgroupNumberis null
-
getGroup
@Nonnull EntryGroupData getGroup(@Nonnull AbstractOrderData order, @Nonnull Collection<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:
IllegalArgumentException- if group was not found or any of the args is invalid
-
findMaxGroupNumber
Returns max value ofEntryGroupData#groupNumber.- Parameters:
roots- root groups- Returns:
- maximum group number among the whole forest
-