Interface SingleSearchable<E>
- Type Parameters:
E- is the type of the elements aSingleSearchable.
- All Known Subinterfaces:
IArrayList<E>, IContainer<E>, ILinkedList<E>, IMatrix<E>, IMatrixColumn<E>, IMatrixRow<E>, ISqlRecord
- All Known Implementing Classes:
AbstractContainer, AbstractExtendedContainer, ArrayContainerView, ArrayList, ContainerView, FilterContainerView, ImmutableList, IntervallContainerView, IterableContainerView, LinkedList, MappingContainerView, Matrix, MatrixColumn, MatrixRow, MultiContainerView, SingleContainer, SqlRecord
public interface SingleSearchable<E>
- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptiongetOptionalStoredFirst(Predicate<? super E> selector) getStoredAtOneBasedIndex(int oneBasedIndex) <C extends Comparable<C>>
EgetStoredByMax(Function<E, C> comparableMapper) <C extends Comparable<C>>
EgetStoredByMin(Function<E, C> comparableMapper) getStoredFirst(Predicate<? super E> selector) <T extends E>
TgetStoredFirstOfType(Class<T> type) getStoredOne(Predicate<? super E> selector)
-
Method Details
-
getOptionalStoredFirst
- Returns:
- a
Optionalwith the first element of the currentSingleSearchableif the currentSingleSearchableis not empty and if the first element of the currentSingleSearchableis not null, an emptyOptionalotherwise.
-
getOptionalStoredFirst
- Parameters:
selector-- Returns:
- a new
Optionalwith the first element the given selector selects from the currentSingleSearchableif the currentSingleSearchablecontains an element the given selector selects, an emptyOptionalotherwise. Ignores null elements. - Throws:
RuntimeException- if the given selector is null.
-
getStoredAtOneBasedIndex
- Parameters:
oneBasedIndex-- Returns:
- the element at the given oneBasedIndex. The element can be null.
- Throws:
RuntimeException- if the currentSingleSearchabledoes not contain an element at the given oneBasedIndex.
-
getStoredByMax
- Type Parameters:
C- is the type of theComparables the given comparableMapper maps from the elements of the currentSingleSearchable.- Parameters:
comparableMapper-- Returns:
- the element with the biggest
Comparablethe given comparableMapper maps from the elements of the currentSingleSearchable. Ignores null elements. - Throws:
RuntimeException- if the given comparableMapper is null.RuntimeException- if the currentSingleSearchabledoes not contain a non-null element.
-
getStoredByMin
- Type Parameters:
C- is the type of theComparables the given comparableMapper maps from the elements of the currentSingleSearchable.- Parameters:
comparableMapper-- Returns:
- the element with the smallest
Comparablethe given comparableMapper maps from the elements of the currentSingleSearchable. Ignores null elements. - Throws:
RuntimeException- if the given comparableMapper is null.RuntimeException- if the currentSingleSearchabledoes not contain a non-null element.
-
getStoredFirst
E getStoredFirst()- Returns:
- the first element of the current
SingleSearchable. The element can be null. - Throws:
RuntimeException- if the currentSingleSearchableis empty.
-
getStoredFirst
- Parameters:
selector-- Returns:
- the first element the given selector selects from the current
SingleSearchable. Ignores null elements. - Throws:
RuntimeException- if the currentSingleSearchabledoes not contain an element the given selector selects.
-
getStoredFirstOfType
- Type Parameters:
T- is the given type.- Parameters:
type-- Returns:
- the first element from the current
SingleSearchablethat is of the given type. - Throws:
RuntimeException- if the given type is null.RuntimeException- if the currentSingleSearchabledoes not contain an element of the given type.
-
getStoredLast
E getStoredLast()- Returns:
- the last element of the current
SingleSearchable. The element can be null. - Throws:
RuntimeException- if the currentSingleSearchableis empty.
-
getStoredOne
E getStoredOne()- Returns:
- the one element of the current
SingleSearchable. The element can be null. - Throws:
RuntimeException- if the currentSingleSearchableis empty.RuntimeException- if the currentSingleSearchablecontains several elements.
-
getStoredOne
- Parameters:
selector-- Returns:
- the one element the given selector selects from the current
SingleSearchable. Ignores null elements. - Throws:
RuntimeException- if the given selector is null.RuntimeException- if the given selector selects none or several elements from the currentSingleSearchable.
-