Signatures equals now checks identity
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -26,7 +26,7 @@ public abstract class Signature {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return visibility.hashCode() * 2;
|
||||
return visibility.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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[
|
||||
|
Reference in New Issue
Block a user