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>
ACollector
which collects aStream
ofPresentationModel
s into a singlePresentationModel
with 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 PresentationModelCollectors
toCompositePresentationModel()
static <T extends As>
PresentationModeltoCompositePresentationModel(java.lang.Iterable<T> i)
A facility simplified version oftoCompositePresentationModel(java.lang.Iterable, java.util.function.Function)
.static <T extends As>
PresentationModeltoCompositePresentationModel(java.lang.Iterable<T> i, java.util.function.Function<T,java.lang.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 PresentationModelCollectors
toCompositePresentationModel(java.util.Collection<java.lang.Object> roles)
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 Detail
-
toCompositePresentationModel
@Nonnull public static PresentationModelCollectors toCompositePresentationModel(@Nonnull java.util.Collection<java.lang.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
@Nonnull public static PresentationModelCollectors toCompositePresentationModel()
-
toCompositePresentationModel
@Nonnull public static <T extends As> PresentationModel toCompositePresentationModel(@Nonnull java.lang.Iterable<T> i, @Nonnull java.util.function.Function<T,java.lang.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 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()
-
-