Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 78eaee32a -> 70cd22dd4
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/70cd22dd Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/70cd22dd Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/70cd22dd Branch: refs/heads/GROOVY_2_6_X Commit: 70cd22dd421c0071248e9f6abeb3608f66b1d37c Parents: 78eaee3 Author: sunlan <[email protected]> Authored: Thu Nov 23 21:05:02 2017 +0800 Committer: sunlan <[email protected]> Committed: Thu Nov 23 21:06:47 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/70cd22dd/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(); } }
