ValueProvider extends SerializableFunction. However, one cannot use Function.compose because the return type of Function.compose is Function instead of ValueProvider
Consider the following helper method:
public static <R, T, V> ValueProvider<T, V> compose(final ValueProvider<? super T, ? extends R> this_,
final ValueProvider<? super R, ? extends V> after) {
Objects.requireNonNull(this_);
Objects.requireNonNull(after);
return (T t) -> Optional.ofNullable(this_.apply(t)).map(after).orElse(null);
}
it allows you to specifiy a ValueProvider by composing method references
grid.addColumn(compose(Person::getAddress, Address::getCity)) instead of grid.addColumn(p->Optional.ofNullable(p.getAddress()).map(Address::getCity))
This contribution contains Personal Intellectual Property that is and remains owned by its Author. To the fullest extent possible, the Appjars Project and its controlling shareholder are granted a non-exclusive, irrevocable and transferable license under the terms stated in section 1(D) of the Amendment to the Agreement on Intellectual Property in effect.
ValueProvider
extendsSerializableFunction
. However, one cannot useFunction.compose
because the return type ofFunction.compose
isFunction
instead ofValueProvider
Consider the following helper method:
it allows you to specifiy a
ValueProvider
by composing method referencesgrid.addColumn(compose(Person::getAddress, Address::getCity))
instead ofgrid.addColumn(p->Optional.ofNullable(p.getAddress()).map(Address::getCity))
This contribution contains Personal Intellectual Property that is and remains owned by its Author. To the fullest extent possible, the Appjars Project and its controlling shareholder are granted a non-exclusive, irrevocable and transferable license under the terms stated in section 1(D) of the Amendment to the Agreement on Intellectual Property in effect.