- Type Parameters:
C- the type of criteriaT- the type of the elements
- All Known Implementing Classes:
Beans
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
- Author:
- Laird Nelson
-
Method Summary
Modifier and TypeMethodDescriptionlist()Returns an immutableListof all of thisSelectable's elements.static <C,E> Selectable <C, E> of()static <C,E> Selectable <C, E> of(Collection<? extends E> collection, BiFunction<? super E, ? super C, ? extends Boolean> f) Returns aSelectableusing the suppliedCollectionas its elements, and the suppliedBiFunctionas its selector function.static <C,E> Selectable <C, E> ofCaching(Collection<? extends E> collection, BiFunction<? super E, ? super C, ? extends Boolean> f) Returns aSelectableusing the suppliedCollectionas its elements, and the suppliedBiFunctionas its selector function.Selects and returns an immutableListrepresenting a sublist of thisSelectable's elements, as mediated by the supplied criteria.
-
Method Details
-
select
Selects and returns an immutableListrepresenting a sublist of thisSelectable's elements, as mediated by the supplied criteria.Implementations of this method must be idempotent and must return a determinate value.
Implementations of this method must not return
null.Implementations of this method should not call
list(), since that method is typically implemented in terms of this one.- Parameters:
criteria- the criteria to use; may benull- Returns:
- an immutable sublist of this
Selectable's elements; nevernull - See Also:
-
list
Returns an immutableListof all of thisSelectable's elements.Implementations of this method must be idempotent and must return a determinate value.
Implementations of this method must not return
null.The default implementation of this method calls the
select(Object)method withnullas the sole argument.- Returns:
- an immutable
Listof all of thisSelectable's elements; nevernull - See Also:
-
of
static <C,E> Selectable<C,E> of(Collection<? extends E> collection, BiFunction<? super E, ? super C, ? extends Boolean> f) Returns aSelectableusing the suppliedCollectionas its elements, and the suppliedBiFunctionas its selector function.There is no guarantee that this method will return new
Selectableinstances.The
Selectableinstances returned by this method may or may not cache their selections.The selector function must select a sublist from the supplied
Collectionas mediated by the supplied criteria. The selector function must additionally be idempotent and must produce a determinate value when given the same arguments.No validation of these semantics of the selector function is performed.
- Type Parameters:
C- the type of criteriaE- the type of the elements- Parameters:
collection- aCollectionof elements from which sublists may be selected; must not benullf- the selector function; must not benull- Returns:
- a
Selectable; nevernull - Throws:
NullPointerException- if eithercollectionorfisnull
-
of
- Type Parameters:
C- the type of criteriaE- the type of the elements- Returns:
- a
Selectablewhoseselect(Object)method always returns an emptyList; nevernull
-
ofCaching
static <C,E> Selectable<C,E> ofCaching(Collection<? extends E> collection, BiFunction<? super E, ? super C, ? extends Boolean> f) Returns aSelectableusing the suppliedCollectionas its elements, and the suppliedBiFunctionas its selector function.There is no guarantee that this method will return new
Selectableinstances.The
Selectableinstances returned by this method will cache their selections.The selector function must select a sublist from the supplied
Collectionas mediated by the supplied criteria. The selector function must additionally be idempotent and must produce a determinate value when given the same arguments.No validation of these semantics of the selector function is performed.
- Type Parameters:
C- the type of criteriaE- the type of the elements- Parameters:
collection- aCollectionof elements from which sublists may be selected; must not benullf- the selector function; must not benull- Returns:
- a
Selectable; nevernull - Throws:
NullPointerException- if eithercollectionorfisnull
-