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 aSelectablethat 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 aSelectablethat 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 aSelectablethat caches its results.static final <C,E> Selectable <C, E> empty()Returns aSelectablewhoseSelectable.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 aSelectableusing the suppliedCollectionas its elements, and the suppliedBiFunctionas its selector function.static final Selectable<AttributedType, Bean<?>> typesafeReducing(Collection<? extends Bean<?>> beans, Matcher<? super AttributedType, ? super Id> m) Normalizes the suppliedCollectionofBeans and returns aSelectablefor it and the suppliedMatcher.
-
Method Details
-
ambiguityReducing
Returns aSelectablethat 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-
nullSelectable - Throws:
NullPointerException- ifsisnull- See Also:
-
caching
Returns aSelectablethat 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-
nullSelectable - Throws:
NullPointerException- ifselectableisnull- 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 aSelectablethat caches its results.- Type Parameters:
C- the criteria typeE- the element type- Parameters:
selectable- aSelectable; must not benullf- aBiFunctionthat returns a cached result, computing it on demand via its supplied mappingFunctionif necessary; must not benull; normally safe for concurrent use by multiple threads; often a reference to theConcurrentHashMap.computeIfAbsent(Object, Function)method- Returns:
- a non-
nullSelectable - Throws:
NullPointerException- ifselectableorfisnull- See Also:
-
empty
Returns aSelectablewhoseSelectable.select(Object)method always returns an empty, immutableList.- Type Parameters:
C- the criteria typeE- the element type- Returns:
- a non-
nullSelectable
-
filtering
public static <C,E> Selectable<C,E> filtering(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 criteria typeE- the element type- 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
-
typesafeReducing
public static final Selectable<AttributedType,Bean<?>> typesafeReducing(Collection<? extends Bean<?>> beans, Matcher<? super AttributedType, ? super Id> m) Normalizes the suppliedCollectionofBeans and returns aSelectablefor it and the suppliedMatcher.The
Selectabledoes not cache its results.- Parameters:
beans- aCollectionofBeans; must not benullm- anIdMatcher; must not benull- Returns:
- a non-
nullSelectable - Throws:
NullPointerException- if any argument isnull- See Also:
-