List of usage examples for java.lang Class getDeclaredMethods
@CallerSensitive public Method[] getDeclaredMethods() throws SecurityException
From source file:org.apache.sling.models.impl.ReflectionUtil.java
public static List<Method> collectInjectableMethods(Class<?> type) { List<Method> result = new ArrayList<Method>(); while (type != null) { Method[] methods = type.getDeclaredMethods(); addAnnotated(methods, result);//from w w w . j av a2 s .c om addAnnotatedMethodsFromInterfaces(type, result); type = type.getSuperclass(); } return result; }
From source file:MethodHashing.java
/** * Calculate method hashes. This algo is taken from RMI. * //from ww w. j a v a2 s . c om * @param intf * @return the map */ public static Map getInterfaceHashes(Class intf) { // Create method hashes Method[] methods = intf.getDeclaredMethods(); HashMap map = new HashMap(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; try { long hash = methodHash(method); map.put(method.toString(), new Long(hash)); } catch (Exception e) { } } return map; }
From source file:Main.java
static Method getMethod(final Class<?> clz, final String mtdName) { if (clz == null || TextUtils.isEmpty(mtdName)) { return null; }/* w w w. java 2 s .co m*/ Method mtd = null; try { for (Method m : clz.getDeclaredMethods()) { if (m.getName().equals(mtdName)) { mtd = m; mtd.setAccessible(true); break; } } } catch (Exception e) { Log.d(TAG, e.getMessage(), e); } return mtd; }
From source file:Main.java
/** * Returns a {@code Class} object that identifies the * declared class as a return type for the method represented by the given * {@code String name} parameter inside the invoked {@code Class<?> clazz} parameter. * * @param clazz the {@code Class} object whose declared methods to be * checked for the wanted method name. * @param name the method name as {@code String} to be * compared with {@link Method#getName()} * @return the {@code Class} object representing the return type of the given method name. * * @see {@link Class#getDeclaredMethods()} * @see {@link Method#getReturnType()}/*from w w w . java 2 s. co m*/ */ public static Class<?> getMethodReturnType(Class<?> clazz, String name) { if (clazz == null || name == null || name.isEmpty()) { return null; } name = name.toLowerCase(); Class<?> returnType = null; for (Method method : clazz.getDeclaredMethods()) { if (method.getName().equals(name)) { returnType = method.getReturnType(); break; } } return returnType; }
From source file:com.wavemaker.tools.apidocs.tools.parser.util.MethodUtils.java
public static Map<String, Method> getMethodUniqueIdentifierIdMap(Class<?> type) { Map<String, Method> identifierMap = new LinkedHashMap<>(); for (Method method : type.getDeclaredMethods()) { identifierMap.put(getMethodUniqueIdentifierId(method), method); }//from w w w . j av a 2 s .c o m return identifierMap; }
From source file:ca.uhn.fhir.util.ReflectionUtil.java
public static LinkedHashSet<Method> getDeclaredMethods(Class<?> theClazz) { LinkedHashSet<Method> retVal = new LinkedHashSet<Method>(); for (Method next : theClazz.getDeclaredMethods()) { try {/* www. j ava 2 s . c o m*/ Method method = theClazz.getMethod(next.getName(), next.getParameterTypes()); retVal.add(method); } catch (NoSuchMethodException e) { retVal.add(next); } catch (SecurityException e) { retVal.add(next); } } return retVal; }
From source file:com.edmunds.autotest.ClassUtil.java
public static Collection<Method> getAllDeclaredMethods(Class cls) { List<Method> methods = new ArrayList<Method>(); do {/*ww w.j av a 2 s . c o m*/ Collections.addAll(methods, cls.getDeclaredMethods()); cls = cls.getSuperclass(); } while (cls != null); return methods; }
From source file:com.agimatec.validation.jsr303.util.SecureActions.java
public static Method[] getDeclaredMethods(final Class<?> clazz) { return run(new PrivilegedAction<Method[]>() { public Method[] run() { return clazz.getDeclaredMethods(); }/* ww w . ja v a 2 s .c o m*/ }); }
From source file:ReflectionUtils.java
/** * Attempt to find a {@link Method} on the supplied class with the supplied name * and parameter types. Searches all superclasses up to <code>Object</code>. * <p>Returns <code>null</code> if no {@link Method} can be found. * @param clazz the class to introspect//from w ww. java2 s.c om * @param name the name of the method * @param paramTypes the parameter types of the method * @return the Method object, or <code>null</code> if none found */ public static Method findMethod(Class clazz, String name, Class[] paramTypes) { Class searchType = clazz; while (!Object.class.equals(searchType) && searchType != null) { Method[] methods = (searchType.isInterface() ? searchType.getMethods() : searchType.getDeclaredMethods()); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (name.equals(method.getName()) && Arrays.equals(paramTypes, method.getParameterTypes())) { return method; } } searchType = searchType.getSuperclass(); } return null; }
From source file:com.example.captain_miao.grantap.utils.PermissionUtils.java
public static <A extends Annotation> Method findMethodWithRequestCode(Class clazz, Class<A> annotation, int requestCode) { for (Method method : clazz.getDeclaredMethods()) { if (method.isAnnotationPresent(annotation)) { if (isEqualRequestCodeFromAnnotation(method, annotation, requestCode)) { return method; }//from ww w . j a va 2 s. c o m } } return null; }