[findbugs] equals() must return false for null argument

The contract defined by java.lang.Object.equals() requires that it
must return false if passed a null argument.

Change-Id: I0b54beeeaed7fbd87d7e3ea5c4d4f5ae3c7d6137
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn
2011-03-09 23:32:32 +01:00
parent 0ff5ff0112
commit 089f04e516
8 changed files with 16 additions and 0 deletions

View File

@@ -162,6 +162,8 @@ public class ProjectState {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null)
return false;
Grant grant = (Grant) o; Grant grant = (Grant) o;
return group.equals(grant.group) && pattern.equals(grant.pattern); return group.equals(grant.group) && pattern.equals(grant.pattern);
} }

View File

@@ -94,6 +94,8 @@ public class AndPredicate<T> extends Predicate<T> {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (other == null)
return false;
return getClass() == other.getClass() return getClass() == other.getClass()
&& getChildren().equals(((Predicate<?>) other).getChildren()); && getChildren().equals(((Predicate<?>) other).getChildren());
} }

View File

@@ -39,6 +39,8 @@ public abstract class IntPredicate<T> extends OperatorPredicate<T> {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (other == null)
return false;
if (getClass() == other.getClass()) { if (getClass() == other.getClass()) {
final IntPredicate<?> p = (IntPredicate<?>) other; final IntPredicate<?> p = (IntPredicate<?>) other;
return getOperator().equals(p.getOperator()) return getOperator().equals(p.getOperator())

View File

@@ -74,6 +74,8 @@ public class NotPredicate<T> extends Predicate<T> {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (other == null)
return false;
return getClass() == other.getClass() return getClass() == other.getClass()
&& getChildren().equals(((Predicate<?>) other).getChildren()); && getChildren().equals(((Predicate<?>) other).getChildren());
} }

View File

@@ -50,6 +50,8 @@ public abstract class OperatorPredicate<T> extends Predicate<T> {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (other == null)
return false;
if (getClass() == other.getClass()) { if (getClass() == other.getClass()) {
final OperatorPredicate<?> p = (OperatorPredicate<?>) other; final OperatorPredicate<?> p = (OperatorPredicate<?>) other;
return getOperator().equals(p.getOperator()) return getOperator().equals(p.getOperator())

View File

@@ -94,6 +94,8 @@ public class OrPredicate<T> extends Predicate<T> {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (other == null)
return false;
return getClass() == other.getClass() return getClass() == other.getClass()
&& getChildren().equals(((Predicate<?>) other).getChildren()); && getChildren().equals(((Predicate<?>) other).getChildren());
} }

View File

@@ -81,6 +81,8 @@ public class VariablePredicate<T> extends Predicate<T> {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (other == null)
return false;
if (getClass() == other.getClass()) { if (getClass() == other.getClass()) {
final VariablePredicate<?> v = (VariablePredicate<?>) other; final VariablePredicate<?> v = (VariablePredicate<?>) other;
return getName().equals(v.getName()) return getName().equals(v.getName())

View File

@@ -45,6 +45,8 @@ public final class WildPatternPredicate<T> extends OperatorPredicate<T> {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (other == null)
return false;
if (getClass() == other.getClass()) { if (getClass() == other.getClass()) {
final WildPatternPredicate<?> p = (WildPatternPredicate<?>) other; final WildPatternPredicate<?> p = (WildPatternPredicate<?>) other;
return getOperator().equals(p.getOperator()); return getOperator().equals(p.getOperator());