diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules')
6 files changed, 170 insertions, 70 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; + } } diff --git a/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java b/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java index 51e1e69b5d..4e89cbb7d3 100644 --- a/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java +++ b/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java @@ -75,27 +75,6 @@ public class OSGiImplementationImpl extends ImplementationImpl implements OSGiIm } } - private boolean areEqual(Object obj1, Object obj2) { - if (obj1 == obj2) - return true; - if (obj1 == null || obj2 == null) - return false; - return obj1.equals(obj2); - } - - @Override - public boolean equals(Object obj) { - - if (!(obj instanceof OSGiImplementationImpl)) - return super.equals(obj); - OSGiImplementationImpl impl = (OSGiImplementationImpl)obj; - if (!areEqual(bundleSymbolicName, impl.bundleSymbolicName)) - return false; - if (!areEqual(bundleVersion, impl.bundleVersion)) - return false; - return super.equals(obj); - } - public void setBundleSymbolicName(String bundleSymbolicName) { this.bundleSymbolicName = bundleSymbolicName; } @@ -104,4 +83,42 @@ public class OSGiImplementationImpl extends ImplementationImpl implements OSGiIm this.bundleVersion = bundleVersion; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((bundleSymbolicName == null) ? 0 : bundleSymbolicName.hashCode()); + result = prime * result + ((bundleVersion == null) ? 0 : bundleVersion.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof OSGiImplementationImpl)) { + return false; + } + OSGiImplementationImpl other = (OSGiImplementationImpl)obj; + if (bundleSymbolicName == null) { + if (other.bundleSymbolicName != null) { + return false; + } + } else if (!bundleSymbolicName.equals(other.bundleSymbolicName)) { + return false; + } + if (bundleVersion == null) { + if (other.bundleVersion != null) { + return false; + } + } else if (!bundleVersion.equals(other.bundleVersion)) { + return false; + } + return true; + } + } diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java index 8081fb4911..7a73f79a45 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java +++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java @@ -225,4 +225,34 @@ public class SpringImplementation extends ImplementationImpl implements Implemen public void setClassLoader(ClassLoader classLoader) { this.classLoader = classLoader; } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((location == null) ? 0 : location.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof SpringImplementation)) { + return false; + } + SpringImplementation other = (SpringImplementation)obj; + if (location == null) { + if (other.location != null) { + return false; + } + } else if (!location.equals(other.location)) { + return false; + } + return true; + } }
\ No newline at end of file diff --git a/sca-java-2.x/trunk/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java b/sca-java-2.x/trunk/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java index f2f9bf7396..bdf9c81909 100644 --- a/sca-java-2.x/trunk/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java +++ b/sca-java-2.x/trunk/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java @@ -38,8 +38,6 @@ class WebImplementationImpl extends ImplementationImpl implements WebImplementat private List<Property> properties = new ArrayList<Property>(); private List<Reference> references = new ArrayList<Reference>(); - private String uri; - private boolean unresolved; private String webURI; private boolean jsClient = true; @@ -64,22 +62,6 @@ class WebImplementationImpl extends ImplementationImpl implements WebImplementat return references; } - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } - public String getWebURI() { return webURI; } @@ -141,4 +123,34 @@ class WebImplementationImpl extends ImplementationImpl implements WebImplementat this.jsClient = jsClient; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((webURI == null) ? 0 : webURI.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof WebImplementationImpl)) { + return false; + } + WebImplementationImpl other = (WebImplementationImpl)obj; + if (webURI == null) { + if (other.webURI != null) { + return false; + } + } else if (!webURI.equals(other.webURI)) { + return false; + } + return true; + } + } diff --git a/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java index 7bdecc2c3a..58edfdd3ba 100644 --- a/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java +++ b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java @@ -80,16 +80,6 @@ public class WidgetImplementationImpl extends ImplementationImpl implements Widg return TYPE; } - @Override - public String getURI() { - return location; - } - - @Override - public void setURI(String uri) { - this.location = uri; - } - public String getLocation() { return location; } @@ -111,4 +101,34 @@ public class WidgetImplementationImpl extends ImplementationImpl implements Widg public String toString() { return "Widget : " + getLocation(); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((location == null) ? 0 : location.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof WidgetImplementationImpl)) { + return false; + } + WidgetImplementationImpl other = (WidgetImplementationImpl)obj; + if (location == null) { + if (other.location != null) { + return false; + } + } else if (!location.equals(other.location)) { + return false; + } + return true; + } } |