My project contains this package : com.X.Y.Z.controller
This package includes 3 files
ControllerA.java
public class ControllerA {
public static void insert(Context context, ModelA model) {/*do somethings*/}
}
ControllerB.java
public class ControllerB {
public static void insert(Context context, ModelB model) {/*do somethings*/}
}
MainController.java
I use following code to invoke insert method from Controller A or B it depends on some condition
public static void insert(Context context, Object object) {
Class<?> clazz = Class.forName(mClass); //Controller A or B
Method method = clazz.getMethod("insert", ?);
method.invoke(null, ?);
}
how do i pass arguments ? object may be ModelA or ModelB
I apologize if my wording is not true
Aucun commentaire:
Enregistrer un commentaire