Common utility functions
- Util.enumToList - converts list of enum values to list of strings
- Util.getBundle - gets bundle from path and with filename
- Util.getProperties - gets all property values from property file
- Util.getPropery - gets the propery value from property file
- invokeMethodOfClassInJar - invoke a method of a class in a jar
###com.hariram.common.util.Util
- Utility class for common functionalities.
####Static methods in the class are as below:
- List enumToList(List enumList)
- Converts List of Object in an enum to List of String.
- ResourceBundle getBundle(String filePath, String fileName)
- Converts List of Object in an enum to List of String.
- Map<String, String> getProperties(String filePath, String fileName)
- Fetches map of all key-values from a property file at filePath and with fileName.
- String getProperty(String filePath, String fileName, String key)
- Fetches value of the key from a pr###1. com.hariram.common.util.Util
- Utility class for common functionalities.
- Object invokeMethodOfClassInJar(String jarPath, String className, String methodName, Object[] methodArgs)
- invoke methodName of ClassName in jar in jarPath and with methodArgs.
###com.hariram.common.util.DynamicToString
- Class overriding toString method and dynamically listing the values of variables.
####Methods in the class are as below:
- String printString()
- Lists the variables and values of the implementing class
- Usage can be checked in the JUnit test case that has been written for it but below are samples:
-
enum TYPES {A, B, C, D} List list = Util.enumToList(Arrays.asList(TYPES.values())); //Converts the enum to list of string
-
ResourceBundle bundle = Util.getBundle("/opt/","log4j"); //Fetches log4j.properties from /opt.
-
Map<String, String> propertiesMap = Util.getProperties("/opt","log4j"); //Loads all the key-values in /opt/log4j.properties to propertiesMap
-
String propertyValue = Util.getProperty("/opt", "log4j", "log4j.rootLogger"); //Gets the value of the key log4j.rootLogger from /opt/log4j.properties
-
Object obj = Util.invokeMethodOfClassInJar("/opt/myjar.jar","com.test.MyClass","mymethod", null); //Invokes com.test.MyClass.mymethod() from /opt/myjar.jar
Copyright (c) 2014 GitHub, Inc. See the LICENSE file for license rights and limitations (GNU GPL v2.0)