Package com.priint.pubserver.util
Class CollectionUtils
java.lang.Object
com.priint.pubserver.util.CollectionUtils
Various static helper methods for
Collections-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends GetIdentifier & GetContext>
TfindByIdAndContext(Collection<T> c, String identifier, Context context) Looks up an element of a Collection by its identifier (viaGetIdentifier) andContext(viaGetContext).static <T> List<T>getListSortedByComparator(List<T> l, Comparator<T> comp) Sorts aListby aComparatorand returns the sorted list.static <T extends GetSequence>
List<T>getListSortedBySequence(List<T> l) Sorts aListof elements implementingGetSequenceby their sequence.
-
Method Details
-
findByIdAndContext
public static <T extends GetIdentifier & GetContext> T findByIdAndContext(Collection<T> c, String identifier, Context context) Looks up an element of a Collection by its identifier (viaGetIdentifier) andContext(viaGetContext). Returns the first element where the identifier and the context are equal to the parameters.- Parameters:
c- TheCollectionto searchidentifier- The identifier to matchcontext- TheContextto match- Returns:
- The first element of the collection where the identifier and the context are equal to the parameters.
-
getListSortedByComparator
Sorts aListby aComparatorand returns the sorted list.- Parameters:
l- The list to sortcomp- The comparator- Returns:
- The sorted list
- See Also:
-
getListSortedBySequence
Sorts aListof elements implementingGetSequenceby their sequence.- Parameters:
l- The list to sort- Returns:
- The sorted list
- See Also:
-