java.lang.Object
org.microbean.bean.RankedReducer<C,T>
- Type Parameters:
C
- the type of criteriaT
- aRanked
type
- All Implemented Interfaces:
Reducer<C,
T>
- Author:
- Laird Nelson
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionof()
Returns aRankedReducer
implementation.final T
reduce
(List<? extends T> elements, C c, BiFunction<? super List<? extends T>, ? super C, ? extends T> failureHandler) Performs some kind of reductive or filtering operation on the suppliedList
, according to the supplied criteria, and returns the single result, or, if reduction fails, invokes the suppliedBiFunction
with a sublist representing a partial reduction (or an empty list representing a reduction that simply could not be performed), along with the supplied criteria, and returns its result.
-
Method Details
-
reduce
public final T reduce(List<? extends T> elements, C c, BiFunction<? super List<? extends T>, ? super C, ? extends T> failureHandler) Description copied from interface:Reducer
Performs some kind of reductive or filtering operation on the suppliedList
, according to the supplied criteria, and returns the single result, or, if reduction fails, invokes the suppliedBiFunction
with a sublist representing a partial reduction (or an empty list representing a reduction that simply could not be performed), along with the supplied criteria, and returns its result.Implementations of this method must return determinate values.
- Specified by:
reduce
in interfaceReducer<C,
T extends Ranked> - Parameters:
elements
- an immutableList
to reduce; must not benull
; represents a successful selection from a larger collection of elementsc
- the criteria effectively describing the initial selection and the desired reduction; may benull
to indicate no criteria; may be ignored if not needed by an implementationfailureHandler
- aBiFunction
receiving a failed reduction (usually a portion of the suppliedelements
), and the selection and reduction criteria, that returns a substitute reduction (or, more commonly, throws an exception); must not benull
; must be invoked if reduction fails or undefined behavior may result- Returns:
- a single, possibly
null
, element normally drawn or computed from the suppliedelements
, or a synthetic value returned by an invocation of the suppliedfailureHandler
'sBiFunction.apply(Object, Object)
method - See Also:
-
of
Returns aRankedReducer
implementation.- Type Parameters:
C
- the type of criteriaT
- the type of theRanked
reduction- Returns:
- a
RankedReducer
implementation; nevernull
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-