fix some hashcode/equals stuff
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2735 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
f89380f996
commit
2fb3f17eb7
|
@ -36,29 +36,5 @@ public abstract class MethodWarning extends Warning {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = super.hashCode();
|
|
||||||
result = prime * result + ((method == null) ? 0 : method.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (!super.equals(obj))
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
final MethodWarning other = (MethodWarning) obj;
|
|
||||||
if (method == null) {
|
|
||||||
if (other.method != null)
|
|
||||||
return false;
|
|
||||||
} else if (!method.equals(other.method))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,23 +13,24 @@ package com.ibm.wala.util.warnings;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A failure to resolve some entity while processing a particular
|
* A failure to resolve some entity while processing a particular node
|
||||||
* node
|
|
||||||
*
|
*
|
||||||
* @author sfink
|
* @author sfink
|
||||||
*/
|
*/
|
||||||
public class ResolutionFailure<T> extends MethodWarning {
|
public class ResolutionFailure<T> extends MethodWarning {
|
||||||
|
|
||||||
final T ref;
|
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws NullPointerException if node is null
|
* @throws NullPointerException if node is null
|
||||||
*/
|
*/
|
||||||
public ResolutionFailure(CGNode node, T ref, String message) throws NullPointerException {
|
public ResolutionFailure(CGNode node, T ref, String message) throws NullPointerException {
|
||||||
super(Warning.SEVERE, node.getMethod().getReference());
|
super(Warning.SEVERE, node.getMethod().getReference());
|
||||||
this.message = message;
|
if (message == null) {
|
||||||
this.ref = ref;
|
this.message = getClass() + " " + getMethod() + " " + ref;
|
||||||
|
} else {
|
||||||
|
this.message = getClass() + " " + getMethod() + ": " + message + " for " + ref;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResolutionFailure(CGNode node, T ref) {
|
private ResolutionFailure(CGNode node, T ref) {
|
||||||
|
@ -41,11 +42,7 @@ public class ResolutionFailure<T> extends MethodWarning {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getMsg() {
|
public String getMsg() {
|
||||||
if (message == null) {
|
return message;
|
||||||
return getClass() + " " + getMethod() + " " + ref;
|
|
||||||
} else {
|
|
||||||
return getClass() + " " + getMethod() + ": " + message + " for " + ref;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> ResolutionFailure<T> create(CGNode node, T ref, String msg) throws IllegalArgumentException {
|
public static <T> ResolutionFailure<T> create(CGNode node, T ref, String msg) throws IllegalArgumentException {
|
||||||
|
@ -61,39 +58,4 @@ public class ResolutionFailure<T> extends MethodWarning {
|
||||||
}
|
}
|
||||||
return new ResolutionFailure<T>(node, ref);
|
return new ResolutionFailure<T>(node, ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = super.hashCode();
|
|
||||||
result = prime * result + ((message == null) ? 0 : message.hashCode());
|
|
||||||
result = prime * result + ((ref == null) ? 0 : ref.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (!super.equals(obj))
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
final ResolutionFailure other = (ResolutionFailure) obj;
|
|
||||||
if (message == null) {
|
|
||||||
if (other.message != null)
|
|
||||||
return false;
|
|
||||||
} else if (!message.equals(other.message))
|
|
||||||
return false;
|
|
||||||
if (ref == null) {
|
|
||||||
if (other.ref != null)
|
|
||||||
return false;
|
|
||||||
} else if (!ref.equals(other.ref))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public abstract class Warning implements Comparable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public final boolean equals(Object obj) {
|
||||||
if (obj instanceof Warning) {
|
if (obj instanceof Warning) {
|
||||||
Warning other = (Warning) obj;
|
Warning other = (Warning) obj;
|
||||||
return (getMsg().equals(other.getMsg()) && getLevel() == other.getLevel());
|
return (getMsg().equals(other.getMsg()) && getLevel() == other.getLevel());
|
||||||
|
@ -75,7 +75,7 @@ public abstract class Warning implements Comparable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public final int hashCode() {
|
||||||
return 1499 * getMsg().hashCode() + getLevel();
|
return 1499 * getMsg().hashCode() + getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue