Class PresentationModelCollectors

    • Method Detail

      • toCompositePresentationModel

        @Nonnull
        public static PresentationModelCollectors toCompositePresentationModel​(@Nonnull
                                                                               java.util.Collection<java.lang.Object> roles)
        A Collector which collects a Stream of PresentationModels into a single PresentationModel with a Composite 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 resulting PresentationModel
        Returns:
        a PresentationModel
        Since:
        3.2-ALPHA-3 (refactored)
      • toCompositePresentationModel

        @Nonnull
        public static <T extends AsPresentationModel toCompositePresentationModel​(@Nonnull
                                                                                    java.lang.Iterable<T> i,
                                                                                    @Nonnull
                                                                                    java.util.function.Function<T,​java.lang.Object> roleCreator)
        A facility method that creates a composite PresentationModel out of an iterable (which means an array, a collection or a stream) of objects implementing As. For each object in the iterable, its PresentationModel is created by means of invoking its Presentable role. Then all the PresentationModels are aggregated into the composite. A function which creates specific roles for each PresentationModel can be specified. The function can return a single role or multiple roles in form of an array Object[].
        Type Parameters:
        T - the type of the objects
        Parameters:
        i - the Iterable
        roleCreator - the function to create roles
        Returns:
        the composite PresentationModel