Skip to content

Commit

Permalink
fixed warnings arising with up-to-date errorprone
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTTom committed Oct 2, 2019
1 parent 96830b9 commit 17d6d0f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/test/java/org/mockito/internal/matchers/EqualityTest.java
Expand Up @@ -36,5 +36,11 @@ private final class BadEquals {
public boolean equals(Object oth) {
throw new RuntimeException();
}

@Override
public int hashCode()
{
return 1;
}
}
}
Expand Up @@ -29,6 +29,11 @@ class Fake {
public boolean equals(Object obj) {
return true;
}
@Override
public int hashCode()
{
return 1;
}
}

@Test
Expand Down
Expand Up @@ -17,6 +17,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -289,23 +290,26 @@ public Type getOwnerType() {
return ownerType;
}

@Override
public boolean equals(Object other) {
if (other instanceof ParameterizedType) {
ParameterizedType otherParamType = (ParameterizedType) other;
if (this == otherParamType) {
return true;
} else {
return equals(ownerType, otherParamType.getOwnerType())
&& equals(rawType, otherParamType.getRawType())
&& Arrays.equals(actualTypeArguments, otherParamType.getActualTypeArguments());
}
} else {
return false;
return Objects.equals(ownerType, otherParamType.getOwnerType())
&& Objects.equals(rawType, otherParamType.getRawType())
&& Arrays.equals(actualTypeArguments, otherParamType.getActualTypeArguments());
}
return false;
}

private boolean equals(Object a, Object b) {
return (a == b) || (a != null && a.equals(b));
@Override
public int hashCode()
{
return (ownerType==null ? 0: ownerType.hashCode())
+ 3 * (rawType==null ? 0: rawType.hashCode())
+ 9 * Arrays.hashCode(actualTypeArguments);
}
};
}
Expand Down

0 comments on commit 17d6d0f

Please sign in to comment.