Class Selectables
java.lang.Object
org.microbean.bean.Selectables
-
Method Summary
Modifier and TypeMethodDescriptionstatic final <C,
E extends Ranked>
Selectable<C, E> ambiguityReducing
(Selectable<C, E> s) Returns aSelectable
that reduces any ambiguity in the results returned by anotherSelectable
, considering alternate status and rank.static <C,
E> Selectable <C, E> caching
(Selectable<C, E> selectable) Returns aSelectable
that caches its results.static <C,
E> Selectable <C, E> caching
(Selectable<C, E> selectable, BiFunction<? super C, Function<? super C, ? extends List<E>>, ? extends List<E>> f) Returns aSelectable
that caches its results.static final <C,
E> Selectable <C, E> empty()
Returns aSelectable
whoseSelectable.select(Object)
method always returns an empty, immutableList
.static <C,
E> Selectable <C, E> filtering
(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 final Selectable
<AttributedType, Bean<?>> typesafeReducing
(Collection<? extends Bean<?>> beans, Matcher<? super AttributedType, ? super Id> m) Normalizes the suppliedCollection
ofBean
s and returns aSelectable
for it and the suppliedMatcher
.
-
Method Details
-
ambiguityReducing
Returns aSelectable
that reduces any ambiguity in the results returned by anotherSelectable
, considering alternate status and rank.- Type Parameters:
C
- the criteria typeE
- the element type- Parameters:
s
- aSelectable
; must not benull
- Returns:
- a non-
null
Selectable
- Throws:
NullPointerException
- ifs
isnull
- See Also:
-
caching
Returns aSelectable
that caches its results.The cache is unbounded.
- Type Parameters:
C
- the criteria typeE
- the element type- Parameters:
selectable
- aSelectable
; must not benull
- Returns:
- a non-
null
Selectable
- Throws:
NullPointerException
- ifselectable
isnull
- See Also:
-
caching
public static <C,E> Selectable<C,E> caching(Selectable<C, E> selectable, BiFunction<? super C, Function<? super C, ? extends List<E>>, ? extends List<E>> f) Returns aSelectable
that caches its results.- Type Parameters:
C
- the criteria typeE
- the element type- Parameters:
selectable
- aSelectable
; must not benull
f
- aBiFunction
that returns a cached result, computing it on demand via its supplied mappingFunction
if necessary; must not benull
; normally safe for concurrent use by multiple threads; often a reference to theConcurrentHashMap.computeIfAbsent(Object, Function)
method- Returns:
- a non-
null
Selectable
- Throws:
NullPointerException
- ifselectable
orf
isnull
- See Also:
-
empty
Returns aSelectable
whoseSelectable.select(Object)
method always returns an empty, immutableList
.- Type Parameters:
C
- the criteria typeE
- the element type- Returns:
- a non-
null
Selectable
-
filtering
public static <C,E> Selectable<C,E> filtering(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 criteria typeE
- the element type- 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
-
typesafeReducing
public static final Selectable<AttributedType,Bean<?>> typesafeReducing(Collection<? extends Bean<?>> beans, Matcher<? super AttributedType, ? super Id> m) Normalizes the suppliedCollection
ofBean
s and returns aSelectable
for it and the suppliedMatcher
.The
Selectable
does not cache its results.- Parameters:
beans
- aCollection
ofBean
s; must not benull
m
- anIdMatcher
; must not benull
- Returns:
- a non-
null
Selectable
- Throws:
NullPointerException
- if any argument isnull
- See Also:
-