From: Lars K?h. <lk...@us...> - 2003-10-05 17:56:39
|
Update of /cvsroot/clirr/clirr/src/java/net/sf/clirr/event In directory sc8-pr-cvs1:/tmp/cvs-serv23633/src/java/net/sf/clirr/event Modified Files: ApiDifference.java Log Message: override equals so unit tests can compare expected and actual ApiDiffs Index: ApiDifference.java =================================================================== RCS file: /cvsroot/clirr/clirr/src/java/net/sf/clirr/event/ApiDifference.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ApiDifference.java 27 Sep 2003 05:28:43 -0000 1.3 +++ ApiDifference.java 5 Oct 2003 17:56:31 -0000 1.4 @@ -34,15 +34,29 @@ private Severity severity; - private boolean expected; + //private boolean expected; + /** + * Create a new API differnce representation. + * + * @param report a human readable string describing the change that was made. + * @param severity the severity in terms of binary API compatibility. + */ public ApiDifference(String report, Severity severity /*, boolean expected*/) { this.report = report; this.severity = severity; - this.expected = expected; +// this.expected = expected; } + /** + * The Severity of the API difference. ERROR means that clients will + * definately break, WARNING means that clients may break, depending + * on how they use the library. See the eclipse paper for further + * explanation. + * + * @return the severity of the API difference. + */ public Severity getSeverity() { return severity; @@ -53,13 +67,51 @@ return report; } + /* public boolean isExpected() { return expected; } + */ + /** {@inheritDoc} */ public String toString() { - return report; + return report + " (" + severity + ")"; + } + + /** {@inheritDoc} */ + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + + if (!(o instanceof ApiDifference)) + { + return false; + } + + final ApiDifference apiDifference = (ApiDifference) o; + + if (report != null ? !report.equals(apiDifference.report) : apiDifference.report != null) + { + return false; + } + if (severity != null ? !severity.equals(apiDifference.severity) : apiDifference.severity != null) + { + return false; + } + + return true; + } + + public int hashCode() + { + int result; + result = (report != null ? report.hashCode() : 0); + result = 29 * result + (severity != null ? severity.hashCode() : 0); + return result; } } |