poussecafe.doc.graph.Node Maven / Gradle / Ivy
package poussecafe.doc.graph;
public class Node implements Comparable {
private String name;
private Shape shape;
private NodeStyle style;
public static Node box(String name) {
Node node = new Node(name);
node.setShape(Shape.BOX);
return node;
}
public static Node ellipse(String name) {
Node node = new Node(name);
node.setShape(Shape.ELLIPSE);
return node;
}
public Node(String name) {
setName(name);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Shape getShape() {
return shape;
}
public void setShape(Shape shape) {
this.shape = shape;
}
@Override
public int compareTo(Node o) {
return name.compareTo(o.name);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Node other = (Node) obj;
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!name.equals(other.name)) {
return false;
}
return true;
}
public NodeStyle getStyle() {
return style;
}
public void setStyle(NodeStyle style) {
this.style = style;
}
}