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());
}