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

org.reactfx.value.OrElseConst Maven / Gradle / Ivy

The newest version!
package org.reactfx.value;

import javafx.beans.value.ObservableValue;

import org.reactfx.Subscription;

class OrElseConst extends ValBase {
    private final ObservableValue src;
    private final T other;

    OrElseConst(ObservableValue src, T other) {
        this.src = src;
        this.other = other;
    }

    @Override
    protected T computeValue() {
        T val = src.getValue();
        return val != null ? val : other;
    }

    @Override
    protected Subscription connect() {
        return Val.observeInvalidations(src, obs -> invalidate());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy