Package it.tidalwave.ui.core.role.spi
Class PresentationModelCollectors
java.lang.Object
it.tidalwave.util.spi.ArrayListCollectorSupport<PresentationModel,PresentationModel>
it.tidalwave.ui.core.role.spi.PresentationModelCollectors
- All Implemented Interfaces:
Collector<PresentationModel,List<PresentationModel>, PresentationModel>
public class PresentationModelCollectors
extends it.tidalwave.util.spi.ArrayListCollectorSupport<PresentationModel,PresentationModel>
A
Collector which collects a Stream of PresentationModels into a single
PresentationModel with a Composite<PresentationModel> role containing them.- Since:
- 2.0-ALPHA-1
- Author:
- Fabrizio Giudici
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.stream.Collector
Collector.Characteristics -
Method Summary
Modifier and TypeMethodDescriptionfinisher()static PresentationModelCollectorsstatic <T extends it.tidalwave.util.As>
PresentationModeltoCompositePresentationModel(Iterable<? extends T> i, Function<? super T, Object> roleCreator) A facility method that creates a compositePresentationModelout of an iterable (which means an array, a collection or a stream) of objects implementingAs.static <T extends it.tidalwave.util.As>
PresentationModelA facility simplified version oftoCompositePresentationModel(java.lang.Iterable, java.util.function.Function).static PresentationModelCollectorsACollectorwhich collects aStreamofPresentationModels into a singlePresentationModelwith aCompositerole 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) ACollectorwhich collects aStreamofPresentationModels into a singlePresentationModelwith aCompositerole 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 it.tidalwave.util.As> PresentationModel toCompositePresentationModel(@Nonnull Iterable<? extends T> i, @Nonnull Function<? super T, Object> roleCreator) A facility method that creates a compositePresentationModelout of an iterable (which means an array, a collection or a stream) of objects implementingAs. For each object in the iterable, itsPresentationModelis created by means of invoking itsPresentablerole. Then all thePresentationModels are aggregated into the composite. A function which creates specific roles for eachPresentationModelcan 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- theIterableroleCreator- the function to create roles- Returns:
- the composite
PresentationModel
-
toCompositePresentationModel
@Nonnull public static <T extends it.tidalwave.util.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
-