com.datastax.graph.Relationship Maven / Gradle / Ivy
package com.datastax.graph;
public class Relationship {
private long id;
private Vertex start;
private Vertex end;
private Edge connection;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Vertex getStart() {
return start;
}
public void setStart(Vertex start) {
this.start = start;
}
public Vertex getEnd() {
return end;
}
public void setEnd(Vertex end) {
this.end = end;
}
public Edge getConnection() {
return connection;
}
public void setConnection(Edge connection) {
this.connection = connection;
}
public static Relationship build(String startText,String endText,String conn){
Relationship relationship=new Relationship();
Vertex startV=new Vertex();
startV.setName(startText);
relationship.setStart(startV);
Vertex endV=new Vertex();
endV.setName(endText);
relationship.setEnd(endV);
Edge edge=new Edge();
edge.setType(conn);
relationship.setConnection(edge);
return relationship;
}
@Override
public String toString() {
return start.getName()+"-"+connection.getType()+"->"+end.getName();
}
@Override
public boolean equals(Object obj) {
Relationship relationship=(Relationship)obj;
if(this.getStart().getId()==relationship.getStart().getId()
&& this.getEnd().getId()==relationship.getEnd().getId()
&& this.getConnection().getType().equals(relationship.getConnection().getType())){
return true;
}
if(this.getStart().getName().equals(relationship.getStart().getName())
&& this.getEnd().getName().equals(relationship.getEnd().getName())
&& this.getConnection().getType().equals(relationship.getConnection().getType())){
return true;
}
return false;
}
}