public static CachedMethod find(Method method) { CachedMethod[] methods = ReflectionCache.getCachedClass(method.getDeclaringClass()).getMethods(); // for (int i = 0; i < methods.length; i++) { // CachedMethod cachedMethod = methods[i]; // if (cachedMethod.cachedMethod.equals(method)) // return cachedMethod; // } // return null; int i = Arrays.binarySearch(methods, method, COMPARATOR); if (i < 0) return null; return methods[i]; }
private void addInterfaceMethods(Set<CachedClass> interfaces) { MetaMethodIndex.Header header = metaMethodIndex.getHeader(theClass); for (CachedClass c : interfaces) { final CachedMethod[] m = c.getMethods(); for (int i = 0; i != m.length; ++i) { MetaMethod method = m[i]; addMetaMethodToIndex(method, header); } } }
superClass.getMethods(); final CachedMethod[] superMopMethods = superClass.mopMethods; mopMethods.addAll(Arrays.asList(superMopMethods));
public CachedMethod searchMethods(String name, CachedClass[] parameterTypes) { CachedMethod[] methods = getMethods(); CachedMethod res = null; for (CachedMethod m : methods) { if (m.getName().equals(name) && ReflectionCache.arrayContentsEq(parameterTypes, m.getParameterTypes()) && (res == null || res.getReturnType().isAssignableFrom(m.getReturnType()))) res = m; } return res; }
public synchronized void initialize() { if (!isInitialized()) { CachedMethod[] methodArray = theCachedClass.getMethods(); synchronized (theCachedClass) { for (final CachedMethod cachedMethod : methodArray) { if (!cachedMethod.getName().equals(CLOSURE_DO_CALL_METHOD)) continue; closureMethods.add(cachedMethod); } } assignMethodChooser(); initialized = true; } }
public static List<MetaMethod> createMethodList(final String name, final Class declaringClass, final Closure closure) { List<MetaMethod> res = new ArrayList<MetaMethod>(); if (closure instanceof MethodClosure) { MethodClosure methodClosure = (MethodClosure) closure; Object owner = closure.getOwner(); Class ownerClass = (Class) (owner instanceof Class ? owner : owner.getClass()); for (CachedMethod method : ReflectionCache.getCachedClass(ownerClass).getMethods() ) { if (method.getName().equals(methodClosure.getMethod())) { MetaMethod metaMethod = new MethodClosureMetaMethod(name, declaringClass, closure, method); res.add(adjustParamTypesForStdMethods(metaMethod, name)); } } } else { if (closure instanceof GeneratedClosure) { for (CachedMethod method : ReflectionCache.getCachedClass(closure.getClass()).getMethods() ) { if (method.getName().equals("doCall")) { MetaMethod metaMethod = new ClosureMetaMethod(name, declaringClass, closure, method); res.add(adjustParamTypesForStdMethods(metaMethod, name)); } } } else { MetaMethod metaMethod = new AnonymousMetaMethod(closure, name, declaringClass); res.add(adjustParamTypesForStdMethods(metaMethod, name)); } } return res; }
private static void createMetaMethods(final Class extensionClass, final List<MetaMethod> metaMethods, final boolean isStatic) { CachedClass cachedClass = ReflectionCache.getCachedClass(extensionClass); CachedMethod[] methods = cachedClass.getMethods(); for (CachedMethod method : methods) { if (method.isStatic() && method.isPublic() && method.getParamsCount() > 0) { // an extension method is found metaMethods.add(isStatic?new NewStaticMetaMethod(method) : new NewInstanceMetaMethod(method)); } } }
CachedMethod[] methods = ReflectionCache.getCachedClass(theClass).getMethods();
c = iter.next(); CachedMethod[] cachedMethods = c.getMethods(); for (CachedMethod metaMethod : cachedMethods) { addToAllMethodsIfPublic(metaMethod); for (CachedMethod metaMethod : c.getMethods()) { addToAllMethodsIfPublic(metaMethod); addMetaMethodToIndex(metaMethod, header);
Collections.addAll(cachedMethodsList, ReflectionCache.getCachedClass(aClass).getMethods());
private void applyUse(CachedClass cachedClass) { CachedMethod[] methods = cachedClass.getMethods(); for (CachedMethod cachedMethod : methods) { if (cachedMethod.isStatic() && cachedMethod.isPublic()) { CachedClass[] paramTypes = cachedMethod.getParameterTypes(); if (paramTypes.length > 0) { CachedClass metaClass = paramTypes[0]; CategoryMethod mmethod = new CategoryMethod(cachedMethod, metaClass.getTheClass()); final String name = cachedMethod.getName(); CategoryMethodList list = get(name); if (list == null || list.level != level) { list = new CategoryMethodList(name, level, list); put(name, list); } list.add(mmethod); Collections.sort(list); cachePropertyAccessor(mmethod); } } } }
public static CachedMethod find(Method method) { CachedMethod[] methods = ReflectionCache.getCachedClass(method.getDeclaringClass()).getMethods(); // for (int i = 0; i < methods.length; i++) { // CachedMethod cachedMethod = methods[i]; // if (cachedMethod.cachedMethod.equals(method)) // return cachedMethod; // } // return null; int i = Arrays.binarySearch(methods, method, comparator); if (i < 0) return null; return methods[i]; }
public static CachedMethod find(Method method) { CachedMethod[] methods = ReflectionCache.getCachedClass(method.getDeclaringClass()).getMethods(); // for (int i = 0; i < methods.length; i++) { // CachedMethod cachedMethod = methods[i]; // if (cachedMethod.cachedMethod.equals(method)) // return cachedMethod; // } // return null; int i = Arrays.binarySearch(methods, method, comparator); if (i < 0) return null; return methods[i]; }
private void addInterfaceMethods(Set interfaces) { MetaMethodIndex.Header header = metaMethodIndex.getHeader(theClass); for (Iterator iter = interfaces.iterator(); iter.hasNext();) { CachedClass c = (CachedClass) iter.next(); final CachedMethod[] m = c.getMethods(); for (int i=0; i != m.length; ++i) { MetaMethod method = m[i]; addMetaMethodToIndex (method, header); } } }
private void addInterfaceMethods(Set<CachedClass> interfaces) { MetaMethodIndex.Header header = metaMethodIndex.getHeader(theClass); for (CachedClass c : interfaces) { final CachedMethod[] m = c.getMethods(); for (int i = 0; i != m.length; ++i) { MetaMethod method = m[i]; addMetaMethodToIndex(method, header); } } }
private void addInterfaceMethods(Set<CachedClass> interfaces) { MetaMethodIndex.Header header = metaMethodIndex.getHeader(theClass); for (CachedClass c : interfaces) { final CachedMethod[] m = c.getMethods(); for (int i = 0; i != m.length; ++i) { MetaMethod method = m[i]; addMetaMethodToIndex(method, header); } } }
public CachedMethod searchMethods(String name, CachedClass[] parameterTypes) { CachedMethod[] methods = getMethods(); CachedMethod res = null; for (int i = 0; i < methods.length; i++) { CachedMethod m = methods[i]; if (m.getName().equals(name) && ReflectionCache.arrayContentsEq(parameterTypes, m.getParameterTypes()) && (res == null || res.getReturnType().isAssignableFrom(m.getReturnType()))) res = m; } return res; }
public CachedMethod searchMethods(String name, CachedClass[] parameterTypes) { CachedMethod[] methods = getMethods(); CachedMethod res = null; for (CachedMethod m : methods) { if (m.getName().equals(name) && ReflectionCache.arrayContentsEq(parameterTypes, m.getParameterTypes()) && (res == null || res.getReturnType().isAssignableFrom(m.getReturnType()))) res = m; } return res; }
public CachedMethod searchMethods(String name, CachedClass[] parameterTypes) { CachedMethod[] methods = getMethods(); CachedMethod res = null; for (int i = 0; i < methods.length; i++) { CachedMethod m = methods[i]; if (m.getName().equals(name) && ReflectionCache.arrayContentsEq(parameterTypes, m.getParameterTypes()) && (res == null || res.getReturnType().isAssignableFrom(m.getReturnType()))) res = m; } return res; }
public CachedMethod searchMethods(String name, CachedClass[] parameterTypes) { CachedMethod[] methods = getMethods(); CachedMethod res = null; for (int i = 0; i < methods.length; i++) { CachedMethod m = methods[i]; if (m.getName().equals(name) && ReflectionCache.arrayContentsEq(parameterTypes, m.getParameterTypes()) && (res == null || res.getReturnType().isAssignableFrom(m.getReturnType()))) res = m; } return res; }