diff options
Diffstat (limited to 'branches/sca-java-1.x/modules/interface-java')
-rw-r--r-- | branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java b/branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java index 42e45317b7..194a4a9175 100644 --- a/branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java +++ b/branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java @@ -68,6 +68,9 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface { public void setJavaClass(Class<?> javaClass) { this.javaClass = javaClass; + if (javaClass != null) { + this.className = javaClass.getName(); + } } public Class<?> getCallbackClass() { @@ -84,28 +87,47 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface { } @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + @Override public int hashCode() { - return String.valueOf(getName()).hashCode(); + final int prime = 31; + int result = 1; + result = prime * result + ((className == null) ? 0 : className.hashCode()); + return result; } - + @Override public boolean equals(Object obj) { - if (obj == this) { + if (this == obj) return true; - } else if (obj instanceof JavaInterface) { - if (getName() != null) { - return getName().equals(((JavaInterface)obj).getName()); - } else { - return ((JavaInterface)obj).getName() == null; - } - } else { + if (obj == null) + return false; + if (getClass() != obj.getClass()) return false; + JavaInterfaceImpl other = (JavaInterfaceImpl)obj; + if (isUnresolved() || other.isUnresolved()) { + if (className == null) { + if (other.className != null) + return false; + } else if (!className.equals(other.className)) + return false; + } else { + if (javaClass == null) { + if (other.javaClass != null) + return false; + } else if (!javaClass.equals(other.javaClass)) + return false; + if (callbackClass == null) { + if (other.callbackClass != null) + return false; + } else if (!callbackClass.equals(other.callbackClass)) + return false; } - } - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); + return true; } } |