groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Minor refactoring
Date Thu, 23 Nov 2017 13:11:43 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X 3a5eb8658 -> 8f0500be4


Minor refactoring

(cherry picked from commit 7ea3047)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8f0500be
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8f0500be
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8f0500be

Branch: refs/heads/GROOVY_2_4_X
Commit: 8f0500be4191029632b5155d2c0c1cbf4ad91498
Parents: 3a5eb86
Author: sunlan <sunlan@apache.org>
Authored: Thu Nov 23 21:05:02 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Thu Nov 23 21:11:35 2017 +0800

----------------------------------------------------------------------
 src/main/groovy/util/ProxyGenerator.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8f0500be/src/main/groovy/util/ProxyGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/util/ProxyGenerator.java b/src/main/groovy/util/ProxyGenerator.java
index 70c7c48..fb73056 100644
--- a/src/main/groovy/util/ProxyGenerator.java
+++ b/src/main/groovy/util/ProxyGenerator.java
@@ -50,7 +50,8 @@ import java.util.Set;
  * @author Cedric Champeau
  */
 public class ProxyGenerator {
-    private static final Class[] EMPTY_INTERFACE_ARRAY = new Class[0];
+    private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+    private static final Class[] EMPTY_INTERFACE_ARRAY = EMPTY_CLASS_ARRAY;
     private static final Map<Object,Object> EMPTY_CLOSURE_MAP = Collections.emptyMap();
     private static final Set<String> EMPTY_KEYSET = Collections.emptySet();
 
@@ -160,8 +161,8 @@ public class ProxyGenerator {
 
     @SuppressWarnings("unchecked")
     public GroovyObject instantiateAggregate(Map closureMap, List<Class> interfaces,
Class clazz, Object[] constructorArgs) {
-        if (clazz!=null && Modifier.isFinal(clazz.getModifiers())) {
-            throw new GroovyCastException("Cannot coerce a map to class "+clazz.getName()+"
because it is a final class");
+        if (clazz != null && Modifier.isFinal(clazz.getModifiers())) {
+            throw new GroovyCastException("Cannot coerce a map to class " + clazz.getName()
+ " because it is a final class");
         }
         Map<Object,Object> map = closureMap != null ? closureMap : EMPTY_CLOSURE_MAP;
         ProxyGeneratorAdapter adapter = createAdapter(map, interfaces, null, clazz);
@@ -208,7 +209,7 @@ public class ProxyGenerator {
     }
 
     private ProxyGeneratorAdapter createAdapter(Map closureMap, List<Class> interfaces,
Class delegateClass, Class baseClass) {
-        Class[] intfs = interfaces != null ? interfaces.toArray(new Class[interfaces.size()])
: EMPTY_INTERFACE_ARRAY;
+        Class[] intfs = interfaces != null ? interfaces.toArray(EMPTY_CLASS_ARRAY) : EMPTY_INTERFACE_ARRAY;
         Class base = baseClass;
         if (base == null) {
             if (intfs.length > 0) {
@@ -327,7 +328,7 @@ public class ProxyGenerator {
             @Override
             public int hashCode() {
                 Class thisClass = this.get();
-                if (thisClass==null) return 0;
+                if (thisClass == null) return 0;
                 return thisClass.hashCode();
             }
         }


Mime
View raw message