Package sprouts

Interface Viewable.CompositeBuilder<C>

Type Parameters:
C - The type of the item held by the composite Viewable being built.
Enclosing interface:
Viewable<T>

public static interface Viewable.CompositeBuilder<C>
An immutable builder used to declare the properties a composite Viewable is merged from. An instance of this is supplied to the configurator function of the Viewable.of(Object, Function) and Viewable.of(Class, Object, Function) factory methods, where every join(Val, BiFunction) call contributes one property together with the combiner folding its item into the composite item.

Note that this is a persistent value: join(Val, BiFunction) does not modify the builder it is called on, but returns a new one. No change listeners are registered before the configurator has returned, which means an instance of this which escapes from the configurator is completely inert.

  • Method Summary

    Modifier and Type
    Method
    Description
    <V extends @Nullable Object>
    Viewable.CompositeBuilder<C>
    join(Val<V> property, BiFunction<C,V,C> combiner)
    Declares that the item of the supplied property should be folded into the item of the composite Viewable using the supplied combiner, which receives the composite item as folded so far, together with the current item of the property, and returns the updated composite item.
  • Method Details

    • join

      <V extends @Nullable Object> Viewable.CompositeBuilder<C> join(Val<V> property, BiFunction<C,V,C> combiner)
      Declares that the item of the supplied property should be folded into the item of the composite Viewable using the supplied combiner, which receives the composite item as folded so far, together with the current item of the property, and returns the updated composite item.

      The combiners of a composite view are applied in the order in which their properties were joined, so if two of them write to the same part of the composite item, then the one which was joined last wins. A property may also be joined more than once, in which case every join is an independent contribution to the fold, while the property itself is still observed only once.

      Note that the supplied property may be nullable, in which case the combiner must be prepared to receive a null item. The composite item itself may never be null, so a combiner returning null is treated as a failure.

      Type Parameters:
      V - The type of the item held by the supplied property.
      Parameters:
      property - The property whose item should be folded into the composite item.
      combiner - A function receiving the composite item folded so far together with the current item of the supplied property, and returning the updated composite item.
      Returns:
      A new Viewable.CompositeBuilder with the supplied property joined to it.
      Throws:
      NullPointerException - If any of the supplied arguments is null.