Signatures equals now checks identity

This commit is contained in:
oowekyala
2017-06-24 00:12:43 +02:00
parent 6ab9088759
commit df68816b6d
4 changed files with 8 additions and 10 deletions

View File

@ -49,15 +49,11 @@ public final class FieldSignature extends Signature {
@Override
public boolean equals(Object o) {
if (o instanceof FieldSignature) {
FieldSignature f = (FieldSignature) o;
return super.equals(o) && f.isFinal == isFinal && f.isStatic == isStatic;
}
return false;
return this == o;
}
@Override
public int hashCode() {
return super.hashCode() * 16 + (isStatic ? 1 : 0) * 32 + (isFinal ? 1 : 0);
return (isFinal ? 1 : 0) + super.hashCode() << 3 + (isStatic ? 1 : 0) << 1;
}
}

View File

@ -69,13 +69,12 @@ public final class OperationSignature extends Signature {
@Override
public boolean equals(Object o) {
return o instanceof OperationSignature && super.equals(o) && role == ((OperationSignature) o).role
&& isAbstract == ((OperationSignature) o).isAbstract;
return this == o;
}
@Override
public int hashCode() {
return super.hashCode() * 2 + role.hashCode() * 4 + (isAbstract ? 1 : 0);
return (isAbstract ? 1 : 0) + super.hashCode() << 1 + role.hashCode() << 2;
}
/**
@ -102,6 +101,7 @@ public final class OperationSignature extends Signature {
}
}
// TODO:cf clean that up
private static boolean isGetterOrSetter(ASTMethodDeclaration node) {
String name = node.getName();
if (NAME_PATTERN.matcher(name).matches()) {

View File

@ -26,7 +26,7 @@ public abstract class Signature {
@Override
public int hashCode() {
return visibility.hashCode() * 2;
return visibility.hashCode();
}
/**

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<test-data>
<!-- All these tests have been tested against JavaNCSS -->
<code-fragment id="full-example">
<![CDATA[