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

net.sf.andromedaioc.model.beans.ReferenceKey Maven / Gradle / Ivy

The newest version!
package net.sf.andromedaioc.model.beans;

public class ReferenceKey {

    public final static ReferenceKey BY_TYPE = new ReferenceKey(null, ReferenceType.BY_TYPE);

    private final String id;
    private final ReferenceType type;

    public static ReferenceKey newPlainReferenceKey(String id) {
        return new ReferenceKey(id, ReferenceType.PLAIN);
    }

    public static ReferenceKey newInnerReferenceKey(String id) {
        return new ReferenceKey(id, ReferenceType.INNER);
    }

    public static ReferenceKey newUndefinedReferenceKey(String id) {
        return new ReferenceKey(id, ReferenceType.UNDEFINED);
    }

    private ReferenceKey(String id, ReferenceType type) {
        this.id = id;
        this.type = type;
    }

    public String getId() {
        return id;
    }

    public ReferenceType getType() {
        return type;
    }

    public boolean isInner() {
        return ReferenceType.INNER.equals(type);
    }

    @Override
    public boolean equals(Object o) {
        if(this == o) {
            return true;
        }
        if(o == null || getClass() != o.getClass()){
            return false;
        }
        ReferenceKey other = (ReferenceKey) o;
        if(type != null ? !type.equals(other.type) : other.type != null) {
            return false;
        }
        if(id != null ? !id.equals(other.id) : other.id != null) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int result = id == null ? 0 : id.hashCode();
        result = 31 * result + (type == null ? 0 : type.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return type.name() + ":" + id;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy