You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ba...@apache.org on 2006/09/27 21:34:28 UTC
svn commit: r450550 -
/jakarta/commons/proper/lang/branches/LANG_2_2_X/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
Author: bayard
Date: Wed Sep 27 12:34:27 2006
New Revision: 450550
URL: http://svn.apache.org/viewvc?view=rev&rev=450550
Log:
Copied javadoc from the delegated to method. When I put the method back in, I didn't add javadoc.
Modified:
jakarta/commons/proper/lang/branches/LANG_2_2_X/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
Modified: jakarta/commons/proper/lang/branches/LANG_2_2_X/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/branches/LANG_2_2_X/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java?view=diff&rev=450550&r1=450549&r2=450550
==============================================================================
--- jakarta/commons/proper/lang/branches/LANG_2_2_X/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java (original)
+++ jakarta/commons/proper/lang/branches/LANG_2_2_X/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java Wed Sep 27 12:34:27 2006
@@ -294,6 +294,36 @@
);
}
+ /**
+ * <p>This method uses reflection to build a valid hash code.</p>
+ *
+ * <p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private
+ * fields. This means that it will throw a security exception if run under
+ * a security manager, if the permissions are not set up correctly. It is also
+ * not as efficient as testing explicitly.</p>
+ *
+ * <p>If the TestTransients parameter is set to <code>true</code>, transient
+ * members will be tested, otherwise they are ignored, as they are likely
+ * derived fields, and not part of the value of the <code>Object</code>.</p>
+ *
+ * <p>Static fields will not be included. Superclass fields will be included
+ * up to and including the specified superclass. A null superclass is treated
+ * as java.lang.Object.</p>
+ *
+ * <p>Two randomly chosen, non-zero, odd numbers must be passed in. Ideally
+ * these should be different for each class, however this is not vital.
+ * Prime numbers are preferred, especially for the multiplier.</p>
+ *
+ * @param initialNonZeroOddNumber a non-zero, odd number used as the initial value
+ * @param multiplierNonZeroOddNumber a non-zero, odd number used as the multiplier
+ * @param object the Object to create a <code>hashCode</code> for
+ * @param testTransients whether to include transient fields
+ * @param reflectUpToClass the superclass to reflect up to (inclusive),
+ * may be <code>null</code>
+ * @return int hash code
+ * @throws IllegalArgumentException if the Object is <code>null</code>
+ * @throws IllegalArgumentException if the number is zero or even
+ */
public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber,
Object object, boolean testTransients, Class reflectUpToClass)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org