[jboss-cvs] JBossAS SVN: r99153 - projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 8 06:09:43 EST 2010


Author: alesj
Date: 2010-01-08 06:09:43 -0500 (Fri, 08 Jan 2010)
New Revision: 99153

Modified:
   projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java
   projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java
Log:
Small code refactoring.

Modified: projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java	2010-01-08 10:22:18 UTC (rev 99152)
+++ projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java	2010-01-08 11:09:43 UTC (rev 99153)
@@ -21,13 +21,14 @@
 */
 package org.jboss.metadata.spi.scope;
 
-import org.jboss.util.collection.ConcurrentSkipListMap;
-
 import java.io.Serializable;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 
+import org.jboss.util.collection.ConcurrentSkipListMap;
+
 /**
  * The ScopeKey represents a path which is made up of the path entries.  Elements may be added dynamically
  * until the ScopeKey is frozen.  If you want to add more elements to a frozen ScopeKey, clone it
@@ -146,6 +147,7 @@
 
    /**
     * Set to frozen.
+    *
     * @throws IllegalArgumentException if there are no Scope entries added.
     */
    public void freeze()
@@ -157,6 +159,7 @@
    
    /**
     * The returned ScopeKey is immutable and optimized for use at runtime.
+    *
     * @return Optimized immutable ScopeKey
     */
    public ScopeKey getOptimizedKey()
@@ -367,7 +370,7 @@
    /**
     * Clone a ScopeKey instance.
     *
-    * @Return an unfrozen instance (even if the current instance is frozen).
+    * @return an unfrozen instance (even if the current instance is frozen).
     */
    public ScopeKey clone()
    {
@@ -395,20 +398,16 @@
       return scopes.values();
    }
    
-   protected static int computeHashCode(Scope[] scopeArray) 
+   protected static int computeHashCode(Scope[] scopeArray)
    {
-      int hashCode = 0;
-      for (Scope scope : scopeArray)
-         hashCode += scope.getScopeLevel().hashCode();
-      return hashCode;
+      return computeHashCode(Arrays.asList(scopeArray));
    }
 
-   protected static int computeHashCode(Collection<Scope> scopeCollection) 
+   protected static int computeHashCode(Iterable<Scope> scopeCollection)
    {
       int hashCode = 0;
       for (Scope scope : scopeCollection)
          hashCode += scope.getScopeLevel().hashCode();
       return hashCode;
    }
-  
 }

Modified: projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java	2010-01-08 10:22:18 UTC (rev 99152)
+++ projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java	2010-01-08 11:09:43 UTC (rev 99153)
@@ -54,7 +54,6 @@
 
 public final class UnmodifiableScopeKey extends ScopeKey implements Serializable, Cloneable
 {
-
    /** The serialVersionUID */
    private static final long serialVersionUID = -442157853443439820L;
 
@@ -85,7 +84,7 @@
     */
    public UnmodifiableScopeKey(ScopeLevel level, Object qualifier)
    {
-      this( new Scope(level, qualifier));
+      this(new Scope(level, qualifier));
    }
 
    /**
@@ -151,8 +150,6 @@
       return theScopesCollection;
    }
 
-   
-
    /**
     * Get a scope
     *
@@ -230,7 +227,6 @@
       return true;
    }
 
-
    /**
     * Get scope for the specified scopeLevel
     *
@@ -245,7 +241,6 @@
       return getScope(scopeLevel);
    }
 
-
    public String toString()
    {
       return getScopes().toString();
@@ -336,7 +331,6 @@
       throw new IllegalStateException("The scope key is frozen");
    }
 
-   
    /**
     * clone will always return a frozen copy of the UnmodifiableScopeKey.  
     * This is different then ScopeKey.clone(), which returns an unfrozen ScopeKey.
@@ -372,5 +366,4 @@
    {
       return theScopesCollection;
    }
-
 }




More information about the jboss-cvs-commits mailing list