Skip to content

Instantly share code, notes, and snippets.

@asunwoo
Created October 31, 2017 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asunwoo/a1e33366140daccebbf19d1497c18f49 to your computer and use it in GitHub Desktop.
Save asunwoo/a1e33366140daccebbf19d1497c18f49 to your computer and use it in GitHub Desktop.
public T getExperimentImpl(String experimentName, String userId){
Variation variation = this.optimizelyClient.activate(experimentName, userId);
T retobj = null;
try {
String className = this.packageName + "." + variation.getKey();
Class cls = Class.forName(className);
Class partypes[] = new Class[0];
Constructor ct = cls.getConstructor(partypes);
retobj = (T)ct.newInstance();
}
catch (Throwable e) {
System.err.println(e);
e.printStackTrace();
return null;
}
return retobj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment