Skip to content
Snippets Groups Projects
Commit efa6071d authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

hashCode and equals added

parent 10e80cc3
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,48 @@ public class Connection<T> { ...@@ -19,6 +19,48 @@ public class Connection<T> {
this.capacity = capacity; this.capacity = capacity;
} }
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + capacity;
result = prime * result + ((sourcePort == null) ? 0 : sourcePort.hashCode());
result = prime * result + ((targetPort == null) ? 0 : targetPort.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Connection<?> other = (Connection<?>) obj;
if (capacity != other.capacity) {
return false;
}
if (sourcePort == null) {
if (other.sourcePort != null) {
return false;
}
} else if (!sourcePort.equals(other.sourcePort)) {
return false;
}
if (targetPort == null) {
if (other.targetPort != null) {
return false;
}
} else if (!targetPort.equals(other.targetPort)) {
return false;
}
return true;
}
public int getCapacity() { public int getCapacity() {
return capacity; return capacity;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment