Package com.kheops.util
Class CollectionUtils
java.lang.Object
com.kheops.util.CollectionUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
find
(Collection<T> sourceList, SimplePredicate predicate) To find the first object in a collection that fulfills the condition evaluated by the given predicatestatic <T> List
<T> findAll
(Collection<T> sourceList, SimplePredicate predicate) To find all objects in a collection that fulfill the condition evaluated by the given predicatestatic <T> int
indexOf
(Collection<T> sourceList, SimplePredicate predicate) Returns the position in the array where the desired element has been found or -1 if not foundstatic <T> int
indexOf
(T wanted, Collection<T> sourceList) To obtain the position of an element in a collection.static <T> int
indexOf
(T wanted, Collection<T> sourceList, MatcherPredicate predicate) Returns the position in the collection where the desired element has been found or -1 if not found.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
indexOf
Returns the position in the collection where the desired element has been found or -1 if not found. Designed to be used when the the class does not consistently implement the equals() method- Parameters:
predicate
- A delegate object responsible to evaluate if the wanted object matches the target object in the collection
-
indexOf
To obtain the position of an element in a collection. The object must consistently implement the equals() method. -
indexOf
Returns the position in the array where the desired element has been found or -1 if not found -
find
To find the first object in a collection that fulfills the condition evaluated by the given predicate- Returns:
- The first object found or null if no object found
-
findAll
To find all objects in a collection that fulfill the condition evaluated by the given predicate- Returns:
- The first object found or null if no object found
-