package net.ranides.assira.math;

import java.io.Serializable;

/**
 * Mutable boolean wrapper class
 */
public class MutableBoolean implements Comparable<MutableBoolean>, Serializable {

    private static final long serialVersionUID = 2L;

    private boolean value;

    /**
     * Create new instance of MutableBoolean
     *
     * @param value value
     */
    public MutableBoolean(boolean value) {
        this.value = value;
    }

    /**
     * Changes current value
     * @param value value
     */
    public void set(boolean value) {
        this.value = value;
    }


    /**
     * Changes current value to negated one
     */
    public void negate() {
        this.value = !value;
    }

    /**
     * Returns current value
     *
     * @return boolean
     */
    public boolean get() {
        return this.value;
    }

    @Override
    public int compareTo(MutableBoolean value) {
        return Boolean.compare(this.value, value.value);
    }


}
