Search in sources :

Example 51 with AccessibleObject

use of java.lang.reflect.AccessibleObject in project android_frameworks_base by crdroidandroid.

the class ViewDebug method getExportedPropertyMethods.

private static Method[] getExportedPropertyMethods(Class<?> klass) {
    if (sMethodsForClasses == null) {
        sMethodsForClasses = new HashMap<Class<?>, Method[]>(100);
    }
    if (sAnnotations == null) {
        sAnnotations = new HashMap<AccessibleObject, ExportedProperty>(512);
    }
    final HashMap<Class<?>, Method[]> map = sMethodsForClasses;
    Method[] methods = map.get(klass);
    if (methods != null) {
        return methods;
    }
    methods = klass.getDeclaredMethodsUnchecked(false);
    final ArrayList<Method> foundMethods = new ArrayList<Method>();
    for (final Method method : methods) {
        // Ensure the method return and parameter types can be resolved.
        try {
            method.getReturnType();
            method.getParameterTypes();
        } catch (NoClassDefFoundError e) {
            continue;
        }
        if (method.getParameterTypes().length == 0 && method.isAnnotationPresent(ExportedProperty.class) && method.getReturnType() != Void.class) {
            method.setAccessible(true);
            foundMethods.add(method);
            sAnnotations.put(method, method.getAnnotation(ExportedProperty.class));
        }
    }
    methods = foundMethods.toArray(new Method[foundMethods.size()]);
    map.put(klass, methods);
    return methods;
}
Also used : ArrayList(java.util.ArrayList) AccessibleObject(java.lang.reflect.AccessibleObject) Method(java.lang.reflect.Method)

Aggregations

AccessibleObject (java.lang.reflect.AccessibleObject)51 ArrayList (java.util.ArrayList)17 Method (java.lang.reflect.Method)13 Field (java.lang.reflect.Field)9 Annotation (java.lang.annotation.Annotation)7 PropertyModel (org.qi4j.runtime.property.PropertyModel)6 HashSet (java.util.HashSet)5 Property (org.qi4j.api.property.Property)4 BuilderEntityState (org.qi4j.runtime.unitofwork.BuilderEntityState)4 MethodInvocation (org.aopalliance.intercept.MethodInvocation)3 MetaInfo (org.qi4j.api.common.MetaInfo)3 Optional (org.qi4j.api.common.Optional)3 DynamicFinder (com.google.inject.persist.finder.DynamicFinder)2 Finder (com.google.inject.persist.finder.Finder)2 InvocationHandler (java.lang.reflect.InvocationHandler)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashMap (java.util.HashMap)2 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)2 ResourceInjectionTargetMetaData (org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData)2 Module (org.jboss.modules.Module)2