Class PresentationModelCollectors

All Implemented Interfaces:
Collector<PresentationModel,List<PresentationModel>,PresentationModel>

public class PresentationModelCollectors extends ArrayListCollectorSupport<PresentationModel,PresentationModel>
A Collector which collects a Stream of PresentationModels into a single PresentationModel with a Composite&lt;PresentationModel&gt; role containing them.
Author:
Fabrizio Giudici
  • Method Details

    • toCompositePresentationModel

      @Nonnull public static PresentationModelCollectors toCompositePresentationModel(@Nonnull Collection<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 PresentationModelCollectors 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 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
    • toCompositePresentationModel

      @Nonnull public static <T extends As> PresentationModel toCompositePresentationModel(@Nonnull Iterable<T> i)
      Type Parameters:
      T - the type of the objects
      Parameters:
      i - the Iterable
      Returns:
      the composite PresentationModel
    • finisher

      @Nonnull public Function<List<PresentationModel>,PresentationModel> finisher()