public static <T, U> TransformedProperty<U> map(Property<T> property, Func1<T, U> mapFunction) {
        Assert.requireNonNull(property, "property");
        Assert.requireNonNull(mapFunction, "mapFunction");

        final PublishSubject<T> reactiveObservable = PublishSubject.create();

        Subscription basicSubscription = property.onChanged(new ValueChangeListener<T>() {
            @Override
            public void valueChanged(ValueChangeEvent<? extends T> evt) {
                reactiveObservable.onNext(evt.getNewValue());
            }
        });

        TransformedPropertyImpl result = new TransformedPropertyImpl<>(basicSubscription);

        Observable<U> transformedObservable = reactiveObservable.map(mapFunction);
        transformedObservable.subscribe(result);

        reactiveObservable.onNext(property.get());

        return result;
    }
public static < T , U > TransformedProperty < U > map ( Property < T > property , Func1 < T , U > mapFunction ) { Assert . requireNonNull ( property , "property" ) ; Assert . requireNonNull ( mapFunction , "mapFunction" ) ; final PublishSubject < T > reactiveObservable = PublishSubject . create ( ) ; Subscription basicSubscription = property . onChanged ( new ValueChangeListener < T > ( ) { @ Override public void valueChanged ( ValueChangeEvent < ? extends T > evt ) { reactiveObservable . onNext ( evt . getNewValue ( ) ) ; } } ) ; TransformedPropertyImpl result = new TransformedPropertyImpl < > ( basicSubscription ) ; Observable < U > transformedObservable = reactiveObservable . map ( mapFunction ) ; transformedObservable . subscribe ( result ) ; reactiveObservable . onNext ( property . get ( ) ) ; return result ; }
Provides a {@link TransformedProperty} that is "map" transformation of the given {@link Property}.
@param property the property
@param mapFunction the function that does the mapping for the transformation
@param <T> type of the property
@return the transformed property