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

api.TreeValue Maven / Gradle / Ivy

The newest version!
package api;

import java.util.Objects;

/**
 * Created by chief on 06.07.17.
 */
public abstract class TreeValue {
    private final V value;
    private Node ownerNode;

    protected TreeValue(V value) {
        assert value != null;
        this.value = value;
    }

    public V getValue(){
        return value;
    }

    public Node getOwnerNode() {
        if (ownerNode == null){
            throw new IllegalStateException("Owner node not set.");
        }
        return ownerNode;
    }

    public void setOwnerNode(Node ownerNode) {
        assert ownerNode != null;
        this.ownerNode = ownerNode;
    }

    public abstract String getValueString();

    @Override
    public String toString() {
        return getValueString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TreeValue treeValue = (TreeValue) o;
        return Objects.equals(getValue(), treeValue.getValue());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getValue());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy