How to save class method in database?

medi :

Is it possible to read all the methods of a java class and save their names in the database?

@Entity
public class Action {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    public Action() {
    }

    public String methodA() {
        return "methodA";
    }

    public String methodB() {
        return "methodB";
    }
}
Horatiu Jeflea :

Use Java reflection:

Method[] methods = Action.class.getDeclaredMethods();

for (int i = 0; i < methods.length; i++) {
     saveToDB(methods[i].toString());
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=194754&siteId=1