[jboss-cvs] JBossAS SVN: r77189 - projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 19 08:42:44 EDT 2008
Author: alesj
Date: 2008-08-19 08:42:44 -0400 (Tue, 19 Aug 2008)
New Revision: 77189
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/AbstractElement.java
projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultElement.java
projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java
Log:
[JBDEPLOY-74]; hash and equals impl on Element.
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/AbstractElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/AbstractElement.java 2008-08-19 11:13:03 UTC (rev 77188)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/AbstractElement.java 2008-08-19 12:42:44 UTC (rev 77189)
@@ -93,4 +93,33 @@
AnnotatedElement annotatedElement = getAnnotatedElement();
return annotatedElement.getAnnotation(annClass);
}
+
+ public int getHashCode()
+ {
+ int hash = className.hashCode();
+ hash += 7 * annClass.hashCode();
+ if (annotation != null)
+ hash += 11 * annotation.hashCode();
+ return hash;
+ }
+
+ @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"})
+ public boolean equals(Object obj)
+ {
+ Class<?> clazz = getClass();
+ if (clazz.isInstance(obj) == false)
+ return false;
+
+ AbstractElement ae = AbstractElement.class.cast(obj);
+ if (className.equals(ae.className) == false)
+ return false;
+ if (annClass.equals(ae.annClass) == false)
+ return false;
+
+ // we don't check annotation
+ // since I doubt classname + annClass + signature + aoClass is not enough
+ // the only way this could happen is probably if class was diff version - diff annotation values
+
+ return true;
+ }
}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultElement.java 2008-08-19 11:13:03 UTC (rev 77188)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultElement.java 2008-08-19 12:42:44 UTC (rev 77189)
@@ -94,4 +94,27 @@
return aoClass.cast(result);
}
+
+ public int getHashCode()
+ {
+ int hash = super.getHashCode();
+ hash += 19 * signature.hashCode();
+ hash += 37 * aoClass.hashCode();
+ return hash;
+ }
+
+ @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"})
+ public boolean equals(Object obj)
+ {
+ if (super.equals(obj) == false)
+ return false;
+
+ DefaultElement de = DefaultElement.class.cast(obj);
+ if (aoClass.equals(de.aoClass) == false)
+ return false;
+ if (signature.equals(de.signature) == false)
+ return false;
+
+ return true;
+ }
}
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java 2008-08-19 11:13:03 UTC (rev 77188)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java 2008-08-19 12:42:44 UTC (rev 77189)
@@ -23,12 +23,14 @@
import java.lang.ref.WeakReference;
+import org.jboss.util.JBossObject;
+
/**
* ClassLoader holder helper.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-abstract class WeakClassLoaderHolder
+abstract class WeakClassLoaderHolder extends JBossObject
{
private transient WeakReference<ClassLoader> clRef;
More information about the jboss-cvs-commits
mailing list