Author: ggregory
Date: Mon May 12 14:50:21 2014
New Revision: 1593985
URL: http://svn.apache.org/r1593985
Log:
Add hashCode() and equals(); needed for JSON and XML IO testing.
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java?rev=1593985&r1=1593984&r2=1593985&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
(original)
+++
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
Mon May 12 14:50:21 2014
@@ -44,6 +44,38 @@ public class StackTracePackageElement im
this.exact = exact;
}
+@Override
+public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ StackTracePackageElement other = (StackTracePackageElement) obj;
+ if (this.exact != other.exact) {
+ return false;
+ }
+ if (this.location == null) {
+ if (other.location != null) {
+ return false;
+ }
+ } else if (!this.location.equals(other.location)) {
+ return false;
+ }
+ if (this.version == null) {
+ if (other.version != null) {
+ return false;
+ }
+ } else if (!this.version.equals(other.version)) {
+ return false;
+ }
+ return true;
+}
+
/**
* Returns the indicator of whether this is an exact match.
*
@@ -72,6 +104,16 @@ public class StackTracePackageElement im
}
@Override
+public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (this.exact ? 1231 : 1237);
+ result = prime * result + ((this.location == null) ? 0 :
this.location.hashCode());
+ result = prime * result + ((this.version == null) ? 0 :
this.version.hashCode());
+ return result;
+}
+
+ @Override
public String toString() {
final String exactStr = exact ? "" : "~";
return exactStr + '[' + location + ':' + version + ']';