Check if method Has Parameter by parameter's Class - Android java.lang.reflect

Android examples for java.lang.reflect:Method

Description

Check if method Has Parameter by parameter's Class

Demo Code


//package com.java2s;

import java.lang.reflect.Method;

public class Main {
    public static boolean methodHasParameter(Method method,
            Class parameterType) {
        Class<?>[] parameters = method.getParameterTypes();
        return parameters.length >= 1
                && parameters[0].isAssignableFrom(parameterType);
    }/* w w w.  j  a va 2s . c o  m*/
}

Related Tutorials