Package it.tidalwave.role.ui.spi
Class PresentationModelCollectors
java.lang.Object
it.tidalwave.util.spi.ArrayListCollectorSupport<PresentationModel,PresentationModel>
it.tidalwave.role.ui.spi.PresentationModelCollectors
- All Implemented Interfaces:
Collector<PresentationModel,
List<PresentationModel>, PresentationModel>
public class PresentationModelCollectors
extends ArrayListCollectorSupport<PresentationModel,PresentationModel>
A
Collector
which collects a Stream
of PresentationModel
s into a single
PresentationModel
with a Composite<PresentationModel>
role containing them.- Author:
- Fabrizio Giudici
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.stream.Collector
Collector.Characteristics
-
Method Summary
Modifier and TypeMethodDescriptionfinisher()
static PresentationModelCollectors
static <T extends As>
PresentationModeltoCompositePresentationModel
(Iterable<? extends T> i, Function<? super T, Object> roleCreator) A facility method that creates a compositePresentationModel
out of an iterable (which means an array, a collection or a stream) of objects implementingAs
.static <T extends As>
PresentationModelA facility simplified version oftoCompositePresentationModel(java.lang.Iterable, java.util.function.Function)
.static PresentationModelCollectors
ACollector
which collects aStream
ofPresentationModel
s into a singlePresentationModel
with aComposite
role containing them.Methods inherited from class it.tidalwave.util.spi.ArrayListCollectorSupport
accumulator, characteristics, combiner, supplier
-
Method Details
-
toCompositePresentationModel
@Nonnull public static PresentationModelCollectors toCompositePresentationModel(@Nonnull Collection<Object> roles) ACollector
which collects aStream
ofPresentationModel
s into a singlePresentationModel
with aComposite
role containing them. In other words:List<PresentationModel> pms = ... PresentationModel compositePm = pms.stream().collect(toCompositePresentationModel()); // same contents as childrenPms List<PresentationModel> childrenPms = compositePm.as(_Composite_).findChildren().results();
- Parameters:
roles
- some extra roles included in the resultingPresentationModel
- Returns:
- a
PresentationModel
- Since:
- 3.2-ALPHA-3 (refactored)
-
toCompositePresentationModel
-
toCompositePresentationModel
@Nonnull public static <T extends As> PresentationModel toCompositePresentationModel(@Nonnull Iterable<? extends T> i, @Nonnull Function<? super T, Object> roleCreator) A facility method that creates a compositePresentationModel
out of an iterable (which means an array, a collection or a stream) of objects implementingAs
. For each object in the iterable, itsPresentationModel
is created by means of invoking itsPresentable
role. Then all thePresentationModel
s are aggregated into the composite. A function which creates specific roles for eachPresentationModel
can be specified. The function can return a single role or multiple roles in form of an arrayObject[]
.- Type Parameters:
T
- the type of the objects- Parameters:
i
- theIterable
roleCreator
- the function to create roles- Returns:
- the composite
PresentationModel
-
toCompositePresentationModel
@Nonnull public static <T extends As> PresentationModel toCompositePresentationModel(@Nonnull Iterable<T> i) A facility simplified version oftoCompositePresentationModel(java.lang.Iterable, java.util.function.Function)
.- Type Parameters:
T
- the type of the objects- Parameters:
i
- theIterable
- Returns:
- the composite
PresentationModel
-
finisher
-