Interface Viewable.CompositeBuilder<C>
- Type Parameters:
C- The type of the item held by the compositeViewablebeing built.
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 TypeMethodDescription<V extends @Nullable Object>
Viewable.CompositeBuilder<C>join(Val<V> property, BiFunction<C, V, C> combiner) Declares that the item of the suppliedpropertyshould be folded into the item of the compositeViewableusing the suppliedcombiner, 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 suppliedpropertyshould be folded into the item of the compositeViewableusing the suppliedcombiner, 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
propertymay be nullable, in which case thecombinermust be prepared to receive anullitem. The composite item itself may never benull, so a combiner returningnullis 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.CompositeBuilderwith the supplied property joined to it. - Throws:
NullPointerException- If any of the supplied arguments isnull.
-