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

org.vertexium.DefaultElementId Maven / Gradle / Ivy

There is a newer version: 4.10.0
Show newest version
package org.vertexium;

public class DefaultElementId implements ElementId {
    private final ElementType elementType;
    private final String id;

    public DefaultElementId(ElementType elementType, String id) {
        this.elementType = elementType;
        this.id = id;
    }

    @Override
    public ElementType getElementType() {
        return elementType;
    }

    @Override
    public String getId() {
        return id;
    }

    @Override
    public int hashCode() {
        return getId().hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ElementId) {
            ElementId objElementId = (ElementId) obj;
            return getId().equals(objElementId.getId()) && getElementType().equals(objElementId.getElementType());
        }
        return super.equals(obj);
    }

    @Override
    public String toString() {
        if (this instanceof Edge) {
            Edge edge = (Edge) this;
            return getId() + ":[" + edge.getVertexId(Direction.OUT) + "-" + edge.getLabel() + "->" + edge.getVertexId(Direction.IN) + "]";
        }
        return getId();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy