Class RankedReducer<C,T extends Ranked>
java.lang.Object
org.microbean.bean.RankedReducer<C,T>
- Type Parameters:
C- the type of criteria used in thereduce(List, Object, BiFunction)methodT- aRankedtype
- All Implemented Interfaces:
Reducer<C,T>
- Author:
- Laird Nelson
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionof()Returns aRankedReducerimplementation.final Treduce(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 suppliedBiFunctionwith 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:ReducerPerforms 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 suppliedBiFunctionwith 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:
reducein interfaceReducer<C,T extends Ranked> - Parameters:
elements- an immutableListto 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 benullto indicate no criteria; may be ignored if not needed by an implementationfailureHandler- aBiFunctionreceiving 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'sapply(Object, Object)method - See Also:
-
of
Returns aRankedReducerimplementation.- Type Parameters:
C- the type of criteriaT- the type of theRankedreduction- Returns:
- a
RankedReducerimplementation; 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.
-