1 package net.sf.crispy.util; 2 3 import java.util.Collection; 4 import java.util.Map; 5 6 7 public class Edge { 8 9 public Object from = null; 10 public Object to = null; 11 public String methodName = null; 12 13 public Edge(Object pvFrom, Object pvTo) { 14 from = pvFrom; 15 to = pvTo; 16 } 17 18 public Object getFrom() { return from; } 19 public Object getTo() { return to; } 20 21 public void setMethodName(String pvMethodName) { methodName = pvMethodName; } 22 public String getMethodName() { return methodName; } 23 24 public boolean equals(Object pvObj) { 25 boolean b = false; 26 if (pvObj instanceof Edge) { 27 Edge myEdge = (Edge) pvObj; 28 if ((myEdge.getFrom() == null) || (myEdge.getTo() == null)) { 29 b = false; 30 } else { 31 if (isCollectionOrMap(from) == false && isCollectionOrMap(to) == false) { 32 b = ((myEdge.getFrom().equals(from)) && (myEdge.getTo().equals(to))); 33 } 34 } 35 } 36 return b; 37 } 38 39 private boolean isCollectionOrMap(Object pvObject) { 40 boolean b = false; 41 if (pvObject instanceof Collection) { 42 b = true; 43 } 44 else if (pvObject instanceof Map) { 45 b = true; 46 } 47 return b; 48 } 49 50 public int hashCode() { 51 return from.hashCode() + to.hashCode(); 52 } 53 54 public String toString() { 55 return " Edge: " + from + " (" + from.hashCode() + "/" + to.hashCode() + ") -> " + to + (methodName == null ? "--" : " " + methodName ); 56 } 57 58 }