Class CollectionUtils

java.lang.Object
com.kheops.util.CollectionUtils

public class CollectionUtils extends Object
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • indexOf

      public 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. 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

      public static <T> int indexOf(T wanted, Collection<T> sourceList)
      To obtain the position of an element in a collection. The object must consistently implement the equals() method.
    • indexOf

      public static <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 found
    • find

      public static <T> T find(Collection<T> sourceList, SimplePredicate predicate)
      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

      public static <T> List<T> findAll(Collection<T> sourceList, SimplePredicate predicate)
      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