Class IterableExaminer

java.lang.Object
ch.nolix.base.commontype.iterableexaminer.IterableExaminer
All Implemented Interfaces:
IIterableContainAnyExaminer, IIterableContainEqualExaminer, IIterableContainMatchingExaminer, IIterableContainMultipleExaminer, IIterableContainObjectExaminer, IIterableExaminer

public final class IterableExaminer extends Object implements IIterableExaminer
Author:
Silvan Wyss
  • Constructor Details

    • IterableExaminer

      public IterableExaminer()
  • Method Details

    • contains

      public boolean contains(Iterable<?> iterable, Object object)
      Specified by:
      contains in interface IIterableContainObjectExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      object -
      Returns:
      true if the given iterable contains the given object, false otherwise
    • containsAll

      public boolean containsAll(Iterable<?> iterable, Iterable<?> objects)
      Specified by:
      containsAll in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched objects, is considered to be empty when is null
      Returns:
      true if the given iterable contains all of the given objects, false otherwise
    • containsAll

      public boolean containsAll(Iterable<? extends Object> iterable, Object... objects)
      Specified by:
      containsAll in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched objects, is considered to be empty when is null
      Returns:
      true if the given iterable contains all of the given objects, false otherwise
    • containsAny

      public boolean containsAny(Iterable<?> iterable)
      The time complexity of this method is O(1).
      Specified by:
      containsAny in interface IIterableContainAnyExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      Returns:
      true if the given iterable contains an element, false otherwise
    • containsAny

      public boolean containsAny(Iterable<?> iterable, Iterable<?> objects)
      Specified by:
      containsAny in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched objects, is considered to be empty when is null
      Returns:
      true if the given iterable contains any of the given objects, false otherwise
    • containsAny

      public boolean containsAny(Iterable<?> iterable, Object... objects)
      Specified by:
      containsAny in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched objects, is considered to be empty when is null
      Returns:
      true if the given iterable contains any of the given objects, false otherwise
    • containsEqual

      public boolean containsEqual(Iterable<?> iterable, Object object)
      The time complexity of this method is O(n) if the current IIterableContainEqualExaminer contains n elements.
      Specified by:
      containsEqual in interface IIterableContainEqualExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      object - the object of which an equal element will be searched for
      Returns:
      true if the given iterable contains an element that equals the given object, false otherwise
    • containsExactlyAll

      public boolean containsExactlyAll(Iterable<?> iterable, Iterable<?> objects)
      Specified by:
      containsExactlyAll in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched objects, is considered to be empty when is null
      Returns:
      true if the given iterable contains exactly all the given objects, false otherwise
    • containsExactlyAll

      public boolean containsExactlyAll(Iterable<?> iterable, Object... objects)
      Specified by:
      containsExactlyAll in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched objects, is considered to be empty when is null
      Returns:
      true if the given iterable contains exactly all the given objects, false otherwise
    • containsExactlyAllEqualInSameOrder

      public boolean containsExactlyAllEqualInSameOrder(Iterable<?> iterable, Iterable<?> objects)
      Specified by:
      containsExactlyAllEqualInSameOrder in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched for objects, is considered to be empty when is null
      Returns:
      true if the given iterable contains exactly such elements that equal the given objects in the same order, false otherwise
    • containsExactlyAllInSameOrder

      public boolean containsExactlyAllInSameOrder(Iterable<?> iterable, Iterable<?> objects)
      Specified by:
      containsExactlyAllInSameOrder in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched for objects, is considered to be empty when is null
      Returns:
      true if the given iterable contains exactly all the given objects in the same order, false otherwise
    • containsExactlyAllInSameOrder

      public boolean containsExactlyAllInSameOrder(Iterable<?> iterable, Object... objects)
      Specified by:
      containsExactlyAllInSameOrder in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched objects, is considered to be empty when is null
      Returns:
      true if the given iterable contains exactly all the given objects in the same order, false otherwise
    • containsMatching

      public <T> boolean containsMatching(Iterable<T> iterable, Predicate<T> selector)
      Specified by:
      containsMatching in interface IIterableContainMatchingExaminer
      Type Parameters:
      T - the type of the elements of the given iterable
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      selector - can select elements, is considered not to select any element when is null
      Returns:
      true if the given iterable contains an element the given selector selects, false otherwise, ignoring null elements in the given iterable
    • containsMatchingOnly

      public <T> boolean containsMatchingOnly(Iterable<T> iterable, Predicate<T> selector)
      Specified by:
      containsMatchingOnly in interface IIterableContainMatchingExaminer
      Type Parameters:
      T - the type of the elements of the given iterable
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      selector - can select elements, is considered not to select any element when is null
      Returns:
      true if the given iterable contains only elements the given selector selects, but at least 1 time, false otherwise, ignoring null elements in the given iterable.
    • containsNoEqual

      public boolean containsNoEqual(Iterable<?> iterable, Object object)
      The time complexity of this method is O(n) if the current IIterableContainEqualExaminer contains n elements.
      Specified by:
      containsNoEqual in interface IIterableContainEqualExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      object - the object of which equal elements will be searched for
      Returns:
      true if the given iterable does not contain an element that equals the given object, false otherwise
    • containsNoMatching

      public <T> boolean containsNoMatching(Iterable<T> iterable, Predicate<T> selector)
      Specified by:
      containsNoMatching in interface IIterableContainMatchingExaminer
      Type Parameters:
      T - the type of the elements of the given iterable
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      selector - can select elements, is considered not to select any element when is null
      Returns:
      true if the given iterable does not contain an element the given selector selects, false otherwise, ignoring null elements in the given iterable.
    • containsNone

      public boolean containsNone(Iterable<?> iterable, Iterable<?> objects)
      Specified by:
      containsNone in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched objects, is considered to be empty when is null
      Returns:
      true if the given iterable does not contain any of the given objects, false otherwise
    • containsNone

      public boolean containsNone(Iterable<?> iterable, Object... objects)
      Specified by:
      containsNone in interface IIterableContainMultipleExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      objects - the searched objects, is considered to be empty when is null
      Returns:
      true if the given iterable does not contain any of the given objects, false otherwise
    • containsNonNull

      public boolean containsNonNull(Iterable<?> iterable)
      The time complexity of this method is O(n) if the given iterable contains n elements.
      Specified by:
      containsNonNull in interface IIterableContainAnyExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      Returns:
      true if the given iterable contains a non-null element, false otherwise
    • containsOnce

      public boolean containsOnce(Iterable<?> iterable, Object object)
      Specified by:
      containsOnce in interface IIterableContainObjectExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      object -
      Returns:
      true if the given iterable contains the given object exactly 1 time, false otherwise
    • containsOne

      public boolean containsOne(Iterable<?> iterable)
      The time complexity of this method is O(1).
      Specified by:
      containsOne in interface IIterableContainAnyExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      Returns:
      true if the given iterable contains exactly 1 element, false otherwise
    • containsOneEqual

      public boolean containsOneEqual(Iterable<?> iterable, Object object)
      The time complexity of this method is O(n) if the current IIterableContainEqualExaminer contains n elements.
      Specified by:
      containsOneEqual in interface IIterableContainEqualExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      object - the object of which exactly 1 equal element will be searched for
      Returns:
      true if the given iterable contains exactly 1 element that equals the given object, false otherwise
    • containsOneMatching

      public <T> boolean containsOneMatching(Iterable<T> iterable, Predicate<T> selector)
      Specified by:
      containsOneMatching in interface IIterableContainMatchingExaminer
      Type Parameters:
      T - the type of the elements of the given iterable
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      selector - can select elements, is considered not to select any element when is null
      Returns:
      true if the given iterable contains exactly 1 element the given selector selects, false otherwise, ignoring null elements in the given iterable.
    • containsOneNoneNull

      public boolean containsOneNoneNull(Iterable<?> iterable)
      The time complexity of this method is O(n) if the given iterable contains n elements.
      Specified by:
      containsOneNoneNull in interface IIterableContainAnyExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      Returns:
      true if the given iterable contains exactly 1 non-null element, false otherwise
    • containsOnly

      public boolean containsOnly(Iterable<?> iterable, Object object)
      Specified by:
      containsOnly in interface IIterableContainObjectExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      object -
      Returns:
      true if the given iterable contains only the given object, but at least 1 time, false otherwise
    • isEmpty

      public boolean isEmpty(Iterable<?> iterable)
      The time complexity of this method is O(1).
      Specified by:
      isEmpty in interface IIterableContainAnyExaminer
      Parameters:
      iterable - the searched Iterable, is considered to be empty when is null
      Returns:
      true if the given iterable is empty, false otherwise