Skip to content

Commit

Permalink
updated Parameter equals function.
Browse files Browse the repository at this point in the history
  • Loading branch information
okram committed Feb 15, 2012
1 parent 95e7ee8 commit 94439f3
Showing 1 changed file with 22 additions and 3 deletions.
Expand Up @@ -5,7 +5,7 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class Parameter<K, V> implements Map.Entry<K, V> {
public class Parameter<K, V> implements Map.Entry<K, V> {

private final K key;
private V value;
Expand All @@ -29,10 +29,29 @@ public V setValue(V value) {
}

public boolean equals(Object object) {
return (object.getClass().equals(Parameter.class) && ((Parameter) object).getKey().equals(this.key) && ((Parameter) object).getValue().equals(this.value));
if (object.getClass().equals(Parameter.class)) {
final Object otherKey = ((Parameter) object).getKey();
final Object otherValue = ((Parameter) object).getValue();
if (otherKey == null) {
if (key != null)
return false;
} else {
if (!otherKey.equals(key))
return false;
}

if (otherValue == null) {
if (value != null)
return false;
} else {
if (!otherValue.equals(value))
return false;
}
}
return false;
}

public String toString() {
return "parameter[" + key.toString() + "," + value.toString() + "]";
return "parameter[" + key + "," + value + "]";
}
}

0 comments on commit 94439f3

Please sign in to comment.