maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r632880 - /maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractRequireFiles.java
Date Sun, 02 Mar 2008 23:36:04 GMT
Author: brianf
Date: Sun Mar  2 15:36:03 2008
New Revision: 632880

URL: http://svn.apache.org/viewvc?rev=632880&view=rev
Log:
MENFORCER-34 restore jdk 1.4 compatibility

Modified:
    maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractRequireFiles.java

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractRequireFiles.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractRequireFiles.java?rev=632880&r1=632879&r2=632880&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractRequireFiles.java
(original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractRequireFiles.java
Sun Mar  2 15:36:03 2008
@@ -68,8 +68,29 @@
      */
     public String getCacheId()
     {
+        return Integer.toString( hashCode( files ) );
+    }
 
-        return "" + Arrays.hashCode( files );
+    /**
+     * Calculates a hash code for the specified array as <code>Arrays.hashCode()</code>
would do. Unfortunately, the
+     * mentioned method is only available for Java 1.5 and later.
+     * 
+     * @param items The array for which to compute the hash code, may be <code>null</code>.
+     * @return The hash code for the array.
+     */
+    private static int hashCode( Object[] items )
+    {
+        int hash = 0;
+        if ( items != null )
+        {
+            hash = 1;
+            for ( int i = 0; i < items.length; i++ )
+            {
+                Object item = items[i];
+                hash = 31 * hash + ( item == null ? 0 : item.hashCode() );
+            }
+        }
+        return hash;
     }
 
     /**



Mime
View raw message