com.gkutiel.github.flip.graph.Vertex Maven / Gradle / Ivy
package com.gkutiel.github.flip.graph;
import java.util.List;
import java.util.Map;
public class Vertex implements Properties {
private final String id;
private final Db db;
public Vertex(final String id, final Db db) {
this.id = id;
this.db = db;
}
@Override
public boolean equals(final Object obj) {
if (obj instanceof Vertex) {
final Vertex v = (Vertex) obj;
return id.equals(v.id);
}
return false;
}
public String getId() {
return id;
}
public List getInEdges(final String label) {
return db.getInEdges(id, label);
};
public List getOutEdges(final String label) {
return db.getOutEdges(id, label);
}
@Override
public Map getProperties() {
return db.getVertexProperties(id);
}
@Override
public String getProperty(final String key) {
return db.getVertexProperty(id, key);
}
@Override
public int hashCode() {
return id.hashCode();
}
@Override
public void setProperty(final String key, final Object value) {
db.setVertexProperty(id, key, value.toString());
}
@Override
public String toString() {
return id + " " + getProperties();
}
}