Is there anybody have good hands in Reflection. Please suggest solution.
Scope of my task is following :-
- I have to get a class at run time
- Use its static Function.
- Pass a static enum variables of another run time class (class MConfiguration) in previous class static Function.
/* Class which have static Enum variable */
public final class MConfiguration {
public static enum Myenum {
ONE("https://abc.org"),
TWO("https://pqrs.org");
private String ourl;
/***
* Constructor.
*
* @param url Configuration URL for this environment.
*/
private Env(final String url) {
ourl = url;
}
I have stuck to use static enum variable. How can i implement [ timlib.init(mContext, Myenum.REFERENCE, true, true); ] by REFLECTION. Following is my implementation.
public String TIIMLIB = "com.rog.lib.sec.timlib";
public String TIMLIB_EVENT = "com.rog.lib.sec.timEvent";
public String TIMIB_ENUM = "com.rog.lib.sec.MConfiguration.Myenum";
/**
* Initialise TimLib API.
*/
public void initTimLib(Context mContext)
{
// timlib.init(mContext, Myenum.REFERENCE, true, true); // actual needs to implement at runtime.
Class cl = Class.forName(TIIMLIB);
}
}