Class CodeHelper

java.lang.Object
net.tangly.core.codes.CodeHelper

public final class CodeHelper extends Object
  • Method Details

    • build

      public static <T extends Enum<T> & Code> CodeType<T> build(Class<T> clazz)
      Utility method to read all code values from an enumeration type implementing the {}@link Code} interface.
      Parameters:
      clazz - class of the reference code
    • build

      public static <T extends Code> CodeType<T> build(Class<T> clazz, Function<ResultSet,T> factory, DataSource dataSource, String tableName) throws SQLException
      Utility 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 code
      factory - placeholder to pass the class constructor as lambda expression
      dataSource - data source to the database to read from
      tableName - 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 IOException
      Utility 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 code
      factory - placeholder to pass the class constructor as lambda expression
      path - uri to the JSON file containing the code values
      Returns:
      code type and all its values
      Throws:
      IOException - if a file access error occurred