diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-17 01:40:44 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-17 01:40:44 +0000 |
commit | 3ded433af820aae000913fa0305380a0f7988c2c (patch) | |
tree | 8f9854db54f0337c4db488e78f5b3d4ac9ac8ba6 /sca-java-2.x/trunk/modules/assembly/src/main/java | |
parent | d65fd2438b4ba4df1967018fc4934db22b47df24 (diff) |
Fix the equals and hashCode to avoid componentType conflicts
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@924089 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/assembly/src/main/java')
2 files changed, 42 insertions, 21 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java index f18c852e69..b52c65ef8b 100644 --- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java +++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java @@ -128,27 +128,6 @@ public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, return service; } - @Override - public int hashCode() { - return String.valueOf(getURI()).hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else { - if (obj instanceof ComponentType) { - if (getURI() != null) { - return getURI().equals(((ComponentType)obj).getURI()); - } else { - return ((ComponentType)obj).getURI() == null; - } - } else { - return false; - } - } - } public List<Intent> getRequiredIntents() { return requiredIntents; @@ -164,4 +143,34 @@ public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, public void setExtensionType(ExtensionType type) { } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((uri == null) ? 0 : uri.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ComponentTypeImpl other = (ComponentTypeImpl)obj; + if (uri == null) { + if (other.uri != null) { + return false; + } + } else if (!uri.equals(other.uri)) { + return false; + } + return true; + } } diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java index 20c7ea3206..599662727a 100644 --- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java +++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java @@ -73,4 +73,16 @@ public abstract class ImplementationImpl extends ComponentTypeImpl implements Im } return impl; } + + // Override the ComponentTypeImpl.hashCode() + @Override + public int hashCode() { + return System.identityHashCode(this); + } + + // Override the ComponentTypeImpl.equals() + @Override + public boolean equals(Object obj) { + return this == obj; + } } |