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:
java.util.stream.Collector<PresentationModel,java.util.List<PresentationModel>,PresentationModel>
public class PresentationModelCollectors extends ArrayListCollectorSupport<PresentationModel,PresentationModel>
ACollectorwhich collects aStreamofPresentationModels into a singlePresentationModelwith aComposite<PresentationModel>role containing them.- Author:
- Fabrizio Giudici
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.function.Function<java.util.List<PresentationModel>,PresentationModel>finisher()static PresentationModelCollectorstoCompositePresentationModel()static <T extends As>
PresentationModeltoCompositePresentationModel(java.lang.Iterable<? extends T> i, java.util.function.Function<? super T,java.lang.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 As>
PresentationModeltoCompositePresentationModel(java.lang.Iterable<T> i)A facility simplified version oftoCompositePresentationModel(java.lang.Iterable, java.util.function.Function).static PresentationModelCollectorstoCompositePresentationModel(java.util.Collection<java.lang.Object> roles)ACollectorwhich collects aStreamofPresentationModels into a singlePresentationModelwith aCompositerole containing them.-
Methods inherited from class it.tidalwave.util.spi.ArrayListCollectorSupport
accumulator, characteristics, combiner, supplier
-
-
-
-
Method Detail
-
toCompositePresentationModel
@Nonnull public static PresentationModelCollectors toCompositePresentationModel(@Nonnull java.util.Collection<java.lang.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
@Nonnull public static PresentationModelCollectors toCompositePresentationModel()
-
toCompositePresentationModel
@Nonnull public static <T extends As> PresentationModel toCompositePresentationModel(@Nonnull java.lang.Iterable<? extends T> i, @Nonnull java.util.function.Function<? super T,java.lang.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 As> PresentationModel toCompositePresentationModel(@Nonnull java.lang.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
@Nonnull public java.util.function.Function<java.util.List<PresentationModel>,PresentationModel> finisher()
-
-