Example usage for java.lang.reflect Executable getParameters

List of usage examples for java.lang.reflect Executable getParameters

Introduction

In this page you can find the example usage for java.lang.reflect Executable getParameters.

Prototype

public Parameter[] getParameters() 

Source Link

Document

Returns an array of Parameter objects that represent all the parameters to the underlying executable represented by this object.

Usage

From source file:MyClass.java

public static ArrayList<String> getParameters(Executable exec) {
    Parameter[] parms = exec.getParameters();
    ArrayList<String> parmList = new ArrayList<>();
    for (int i = 0; i < parms.length; i++) {

        int mod = parms[i].getModifiers() & Modifier.parameterModifiers();
        String modifiers = Modifier.toString(mod);
        String parmType = parms[i].getType().getSimpleName();
        String parmName = parms[i].getName();
        String temp = modifiers + "  " + parmType + "  " + parmName;
        if (temp.trim().length() == 0) {
            continue;
        }/*from ww w .ja  v  a 2 s.com*/
        parmList.add(temp.trim());
    }
    return parmList;
}