- 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 immutableList
of 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 aSelectable
using the suppliedCollection
as its elements, and the suppliedBiFunction
as its selector function.static <C,
E> Selectable <C, E> ofCaching
(Collection<? extends E> collection, BiFunction<? super E, ? super C, ? extends Boolean> f) Returns aSelectable
using the suppliedCollection
as its elements, and the suppliedBiFunction
as its selector function.Selects and returns an immutableList
representing a sublist of thisSelectable
's elements, as mediated by the supplied criteria.
-
Method Details
-
select
Selects and returns an immutableList
representing 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 immutableList
of 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 withnull
as the sole argument.- Returns:
- an immutable
List
of 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 aSelectable
using the suppliedCollection
as its elements, and the suppliedBiFunction
as its selector function.There is no guarantee that this method will return new
Selectable
instances.The
Selectable
instances returned by this method may or may not cache their selections.The selector function must select a sublist from the supplied
Collection
as 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
- aCollection
of elements from which sublists may be selected; must not benull
f
- the selector function; must not benull
- Returns:
- a
Selectable
; nevernull
- Throws:
NullPointerException
- if eithercollection
orf
isnull
-
of
- Type Parameters:
C
- the type of criteriaE
- the type of the elements- Returns:
- a
Selectable
whoseselect(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 aSelectable
using the suppliedCollection
as its elements, and the suppliedBiFunction
as its selector function.There is no guarantee that this method will return new
Selectable
instances.The
Selectable
instances returned by this method will cache their selections.The selector function must select a sublist from the supplied
Collection
as 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
- aCollection
of elements from which sublists may be selected; must not benull
f
- the selector function; must not benull
- Returns:
- a
Selectable
; nevernull
- Throws:
NullPointerException
- if eithercollection
orf
isnull
-