Interface IIterableFirstElementSearcher

All Known Subinterfaces:
IIterableSearcher
All Known Implementing Classes:
IterableSearcher

public interface IIterableFirstElementSearcher
Author:
Silvan Wyss
  • Method Summary

    Modifier and Type
    Method
    Description
    <E> E
    getStoredFirst(Iterable<E> iterable, Predicate<? super E> selector)
    The time complexity of this method is O(n) if the given iterable contains n elements.
    <E> E
    The time complexity of this method is O(n) if the given iterable contains n elements.
    <E, T extends E>
    T
    getStoredFirstOfType(Iterable<E> iterable, Class<T> type)
    The time complexity of this method is O(n) if the given iterable contains n elements.
  • Method Details

    • getStoredFirstNonNull

      <E> E getStoredFirstNonNull(Iterable<E> iterable)
      The time complexity of this method is O(n) if the given iterable contains n elements.
      Type Parameters:
      E - the type of the elements of the given iterable
      Parameters:
      iterable - the searched iterable, is considered to be empty when is null
      Returns:
      the first non-null element of the given iterable
      Throws:
      RuntimeException - if the given iterable does not contain a non-null element
    • getStoredFirst

      <E> E getStoredFirst(Iterable<E> iterable, Predicate<? super E> selector)
      The time complexity of this method is O(n) if the given iterable contains n elements.
      Type Parameters:
      E - 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:
      the first element the given selector selects of the given Iterable, ignoring null elements
      Throws:
      RuntimeException - if the given iterable does not contain an element the given selector selects
    • getStoredFirstOfType

      <E, T extends E> T getStoredFirstOfType(Iterable<E> iterable, Class<T> type)
      The time complexity of this method is O(n) if the given iterable contains n elements.
      Type Parameters:
      E - the type of the elements of the given iterable
      T - the modeled type of the given type
      Parameters:
      iterable - the searched iterable, is considered to be empty when is null
      type -
      Returns:
      the first element of the given iterable that is of the given type
      Throws:
      RuntimeException - if the given type is null
      RuntimeException - if the given iterable does not contain an element of the given type.