Package com.priint.pubserver.util
Class CollectionUtils
- java.lang.Object
-
- com.priint.pubserver.util.CollectionUtils
-
public class CollectionUtils extends java.lang.ObjectVarious static helper methods forCollections
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends GetIdentifier & GetContext>
TfindByIdAndContext(java.util.Collection<T> c, java.lang.String identifier, Context context)Looks up an element of a Collection by its identifier (viaGetIdentifier) andContext(viaGetContext).static <T> java.util.List<T>getListSortedByComparator(java.util.List<T> l, java.util.Comparator<T> comp)Sorts aListby aComparatorand returns the sorted list.static <T extends GetSequence>
java.util.List<T>getListSortedBySequence(java.util.List<T> l)Sorts aListof elements implementingGetSequenceby their sequence.
-
-
-
Method Detail
-
findByIdAndContext
public static <T extends GetIdentifier & GetContext> T findByIdAndContext(java.util.Collection<T> c, java.lang.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
public static <T> java.util.List<T> getListSortedByComparator(java.util.List<T> l, java.util.Comparator<T> comp)Sorts aListby aComparatorand returns the sorted list.- Parameters:
l- The list to sortcomp- The comparator- Returns:
- The sorted list
- See Also:
Collections.sort(List, Comparator)
-
getListSortedBySequence
public static <T extends GetSequence> java.util.List<T> getListSortedBySequence(java.util.List<T> l)
Sorts aListof elements implementingGetSequenceby their sequence.- Parameters:
l- The list to sort- Returns:
- The sorted list
- See Also:
getListSortedByComparator(List, Comparator)
-
-