package net.kiberion.swampmachine.subscription;

import org.springframework.util.ObjectUtils;

public class ObservableInt extends AbstractObservable<Integer, Integer> {

    private Integer value;

    public ObservableInt(int i) {
        value = Integer.valueOf(i);
    }
    
    public ObservableInt() {
        this (0);
    }

    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    protected void setValueInternal(Integer newValue) {
        value = newValue;
    }

    public void increment() {
        setValue(value + 1);
    }

    public void decrement() {
        setValue(value - 1);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ObservableInt) {
            return ObjectUtils.nullSafeEquals(value, ((ObservableInt) obj).getValue());
        } else if (obj instanceof Integer) {
            return ObjectUtils.nullSafeEquals(value, obj);
        }

        return false;
    }

    @Override
    public int hashCode() {
        if (value != null) {
            return value.hashCode();
        }
        return super.hashCode();
    }
}

@@ -626,32 +626,121 @@
 alue - 1);%0A    %7D
+%0A    %0A    public void applyDelta(int delta) %7B%0A        setValue(value + delta);%0A    %7D%0A    
 %0A%0A    @Override%0A

Apply delta method.