package it.integry.integrywmsnative.core.di;

import androidx.databinding.BaseObservable;

public class BindableInteger  extends BaseObservable {
    Integer mValue;

    public BindableInteger() {}

    public BindableInteger(int startValue) {
        this.mValue = startValue;
    }

    public Integer get() {
        return get(true);
    }

    public Integer get(boolean defaultIfNull) {

        if(mValue == null){
            if(defaultIfNull) return 0;
            else return null;
        } else return mValue;
    }

    public void set(Integer value) {
        if (!Objects.equals(this.mValue, value)) {
            this.mValue = value;
            notifyChange();
        }
    }

    public boolean isEmpty() {
        return mValue == null;
    }

}
