Author: adrianc
Date: Fri Sep 9 11:51:13 2011
New Revision: 1167117
URL:
http://svn.apache.org/viewvc?rev=1167117&view=revLog:
A small refactoring of ArtifactInfoBase.java:
1. Fixed infinite recursion reported by Dimitri Unruh (
https://issues.apache.org/jira/browse/OFBIZ-4398).
2. Eliminated expensive repetitive String concatenations.
3. Added hashCode() - since the class implements equals().
Modified:
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java
Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java?rev=1167117&r1=1167116&r2=1167117&view=diff==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java Fri Sep 9 11:51:13 2011
@@ -21,42 +21,58 @@ package org.ofbiz.webtools.artifactinfo;
import java.net.MalformedURLException;
import java.net.URL;
-
-
/**
*
*/
public abstract class ArtifactInfoBase implements Comparable<ArtifactInfoBase> {
+
protected ArtifactInfoFactory aif;
+ private String fullName = null;
public ArtifactInfoBase(ArtifactInfoFactory aif) {
this.aif = aif;
}
+ public int compareTo(ArtifactInfoBase that) {
+ if (that == null) {
+ return -1;
+ }
+ return this.toString().compareTo(that.toString());
+ }
+
@Override
public boolean equals(Object obj) {
- if (obj instanceof ArtifactInfoBase) {
- return this.equals(obj);
- } else {
+ if (this == obj) {
+ return true;
+ }
+ try {
+ ArtifactInfoBase that = (ArtifactInfoBase) obj;
+ return this.toString().equals(that.toString());
+ } catch (Exception e) {
return false;
}
}
- public int compareTo(ArtifactInfoBase that) {
- if (that == null) return -1;
- String thisName = this.getDisplayType() + ":" + this.getDisplayName();
- String thatName = that.getDisplayType() + ":" + that.getDisplayName();
- return thisName.compareTo(thatName);
- }
-
abstract public String getDisplayName();
+
abstract public String getDisplayType();
+
+ abstract public URL getLocationURL() throws MalformedURLException;
+
abstract public String getType();
+
abstract public String getUniqueId();
- abstract public URL getLocationURL() throws MalformedURLException;
+ @Override
+ public int hashCode() {
+ return toString().hashCode();
+ }
- //public static List<ArtifactInfoBase> sortArtifactInfoSetByDisplayName(Set<ArtifactInfoBase> artifactInfoSet) {
- //SortedMap<String, ArtifactInfoBase> sortedMap = FastMap.newInstance();
- //}
+ @Override
+ public String toString() {
+ if (this.fullName == null) {
+ this.fullName = this.getDisplayType().concat(":").concat(this.getDisplayName());
+ }
+ return this.fullName;
+ }
}