Class CodeHelper
java.lang.Object
net.tangly.core.codes.CodeHelper
-
Method Summary
Modifier and TypeMethodDescriptionUtility method to read all code values from an enumeration type implementing the {}@link Code} interface.Utility method to read all code values from a relational database table using Java regular API.Utility method to read all code values from a JSON file using the org.json library.
-
Method Details
-
build
-
build
public static <T extends Code> CodeType<T> build(Class<T> clazz, Function<ResultSet, T> factory, DataSource dataSource, String tableName) throws SQLExceptionUtility method to read all code values from a relational database table using Java regular API.- Type Parameters:
T- class of the reference code- Parameters:
clazz- class of the reference codefactory- placeholder to pass the class constructor as lambda expressiondataSource- data source to the database to read fromtableName- name of the table containing the code values- Returns:
- code type and all its values
- Throws:
SQLException- if a database access error occurred
-
build
public static <T extends Code> CodeType<T> build(Class<T> clazz, Function<org.json.JSONObject, T> factory, Path path) throws IOExceptionUtility method to read all code values from a JSON file using the org.json library.- Type Parameters:
T- class of the reference code- Parameters:
clazz- class of the reference codefactory- placeholder to pass the class constructor as lambda expressionpath- uri to the JSON file containing the code values- Returns:
- code type and all its values
- Throws:
IOException- if a file access error occurred
-