All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netopyr.reduxfx.component.impl.ReduxFXReadOnlyObjectProperty Maven / Gradle / Ivy

package com.netopyr.reduxfx.component.impl;

import com.netopyr.reduxfx.component.command.ObjectChangedCommand;
import io.reactivex.Flowable;
import javafx.beans.property.ReadOnlyObjectPropertyBase;
import org.reactivestreams.Publisher;

public final class ReduxFXReadOnlyObjectProperty extends ReadOnlyObjectPropertyBase {

    private final Object bean;
    private final String name;

    private T value;

    @SuppressWarnings("unchecked")
    public ReduxFXReadOnlyObjectProperty(Object bean, String name, Publisher> receiver) {
        this.bean = bean;
        this.name = name;
        Flowable.fromPublisher(receiver).forEach(command -> {
            this.value = (T) command.getNewValue();
            this.fireValueChangedEvent();
        });
    }

    @Override
    public Object getBean() {
        return bean;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public T get() {
        return value;
    }




}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy