java.lang.Object
com.linkedin.feathr.common.configObj.configbuilder.ConfigUtils

public class ConfigUtils extends Object
Utils to read typesafe configs
  • Field Details

  • Method Details

    • getStringWithDefault

      public static String getStringWithDefault(com.typesafe.config.Config config, String path, String defaultValue)
      return string config value with default
      Parameters:
      config - typesafe config to read value from
      path - path of the config value
      Returns:
      config value
    • getIntWithDefault

      public static int getIntWithDefault(com.typesafe.config.Config config, String path, int defaultValue)
      return int config value with default
      Parameters:
      config - typesafe config to read value from
      path - path of the config value
      Returns:
      config value
    • getNumberWithDefault

      public static Number getNumberWithDefault(com.typesafe.config.Config config, String path, Number defaultValue)
      return numeric config value with default
      Parameters:
      config - typesafe config to read value from
      path - path of the config value
      Returns:
      config value
    • getDurationWithDefault

      public static Duration getDurationWithDefault(com.typesafe.config.Config config, String path, Duration defaultValue)
      return numeric config value with default
      Parameters:
      config - typesafe config to read value from
      path - path of the config value
      Returns:
      config value
    • getLongWithDefault

      public static long getLongWithDefault(com.typesafe.config.Config config, String path, long defaultValue)
      return long config value with default
      Parameters:
      config - typesafe config to read value from
      path - path of the config value
      Returns:
      config value
    • getBooleanWithDefault

      public static boolean getBooleanWithDefault(com.typesafe.config.Config config, String path, Boolean defaultValue)
      return boolean config value with default
      Parameters:
      config - typesafe config to read value from
      path - path of the config value
      Returns:
      config value
    • getStringMap

      public static Map<String,String> getStringMap(com.typesafe.config.Config config)
      return a String map config value where the key and value are both simple String
      Parameters:
      config - the typesafe config containing the String map
      Returns:
      the map value
    • getChronoUnit

      public static ChronoUnit getChronoUnit(String timeResolutionStr)
      convert ChronoUnit String to ChronoUnit enum
      Parameters:
      timeResolutionStr - the timeResolution String
      Returns:
    • validateTimestampPatternWithEpoch

      public static void validateTimestampPatternWithEpoch(String fieldName, String fieldValue, String timestampPattern)
      Check if the input timestamp pattern is valid by checking for epoch/epoch_millis and then invoking the DateTimeFormatter.
      Parameters:
      fieldName - Field name where present to throw a meaningful error message
      timestampPattern - The timestamp pattern string
    • validateTimestampPattern

      public static void validateTimestampPattern(String fieldName, String fieldValue, String timestampPattern)
      Check if the input timestamp pattern is valid by invoking the DateTimeFormatter.
      Parameters:
      fieldName - Field name where present to throw a meaningful error message
      timestampPattern - The timestamp pattern string
    • getStringList

      public static List<String> getStringList(com.typesafe.config.Config config, String path)
      return a String list config value where the value can be either a single String or String list
      Parameters:
      config - the typesafe config to read value from
      path - path of the config value
      Returns:
      config value
    • getHoconString

      public static String getHoconString(com.typesafe.config.Config config, String path)
      Get the typesafe ConfigValue.render() with given path
      Parameters:
      config - the typesafe object to read value from
      path - the path
      Returns:
      String representation for the ConfigValue, and null if the path does not exist