Created
April 19, 2016 22:43
-
-
Save mnrasul/afa932c33a01ebf1c97a1f263d55bbd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// read a value | |
Object value = new PropertyDescriptor(property, clazz).getReadMethod().invoke(object); | |
//write a value | |
/** | |
* | |
* @param className | |
* @param valueToSet | |
* @param property | |
* @throws Exception | |
*/ | |
public static Object setStringValue(String className, String valueToSet, String property) throws Exception { | |
property = UppercaseFirstCharacter(property); | |
Class clazz = Class.forName(className); | |
Object object = clazz.newInstance(); | |
String []inputArray = {valueToSet}; | |
Statement set = new Statement(object, "set"+property, inputArray); | |
set.execute(); | |
return object; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment