Skip to content

Commit

Permalink
Add equals and hashcode to MethodInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
n1hility committed Sep 28, 2018
1 parent 15eb8f4 commit a567382
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/java/org/jboss/jandex/AnnotationInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,7 @@ public boolean equals(Object o) {
public int hashCode() {
int result = name.hashCode();
result = 31 * result + Arrays.hashCode(values);
if(target != null) {
result = 31 * result + target.hashCode();
}

return result;
}
}
16 changes: 16 additions & 0 deletions src/main/java/org/jboss/jandex/MethodInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,22 @@ public String toString() {
return methodInternal.toString();
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;

MethodInfo that = (MethodInfo) o;
return clazz.equals(that.clazz) && methodInternal.equals(that.methodInternal);
}

@Override
public int hashCode() {
return 31 * clazz.hashCode() + methodInternal.hashCode();
}

@Override
public final ClassInfo asClass() {
throw new IllegalArgumentException("Not a class");
Expand Down

0 comments on commit a567382

Please sign in to comment.