MCPcopy Index your code
hub / github.com/apache/groovy / createAdapter

Method createAdapter

src/main/java/groovy/util/ProxyGenerator.java:356–373  ·  view source on GitHub ↗
(final Map<Object,Object> closureMap, final List<Class> interfaceList, final Class delegateClass, final Class baseClass)

Source from the content-addressed store, hash-verified

354 }
355
356 private ProxyGeneratorAdapter createAdapter(final Map<Object,Object> closureMap, final List<Class> interfaceList, final Class delegateClass, final Class baseClass) {
357 Class[] interfaces = interfaceList != null ? interfaceList.toArray(EMPTY_CLASS_ARRAY) : EMPTY_CLASS_ARRAY;
358 final Class<?> base = baseClass != null ? baseClass : (interfaces.length > 0 ? interfaces[0] : Object.class);
359 final int closureMapSize = closureMap.size();
360 Set<String> methodNames = closureMapSize == 0 ? Collections.emptySet() : new HashSet<>(closureMapSize);
361 for (Object key : closureMap.keySet()) {
362 methodNames.add(key.toString());
363 }
364 boolean useDelegate = (delegateClass != null);
365 CacheKey key = new CacheKey(base, useDelegate ? delegateClass : Object.class, methodNames, interfaces, emptyMethods, useDelegate);
366 ClassLoader classLoader = useDelegate ? delegateClass.getClassLoader() : base.getClassLoader();
367
368 synchronized (adapterCache) {
369 return adapterCache.computeIfAbsent(key,
370 k -> new ProxyGeneratorAdapter(closureMap, base, interfaces, classLoader, emptyMethods,
371 useDelegate ? delegateClass : null));
372 }
373 }
374
375 private static void setMetaClass(final MetaClass metaClass) {
376 final MetaClass newMetaClass = new DelegatingMetaClass(metaClass) {

Callers 2

instantiateAggregateMethod · 0.95

Calls 7

sizeMethod · 0.65
addMethod · 0.65
toStringMethod · 0.65
toArrayMethod · 0.45
keySetMethod · 0.45
getClassLoaderMethod · 0.45
computeIfAbsentMethod · 0.45

Tested by

no test coverage detected