Class ConfigUtils
java.lang.Object
com.linkedin.feathr.common.configObj.configbuilder.ConfigUtils
Utils to read typesafe configs
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleangetBooleanWithDefault(com.typesafe.config.Config config, String path, Boolean defaultValue) return boolean config value with defaultstatic ChronoUnitgetChronoUnit(String timeResolutionStr) convert ChronoUnit String to ChronoUnit enumstatic DurationgetDurationWithDefault(com.typesafe.config.Config config, String path, Duration defaultValue) return numeric config value with defaultstatic StringgetHoconString(com.typesafe.config.Config config, String path) Get the typesafeConfigValue.render()with given pathstatic intgetIntWithDefault(com.typesafe.config.Config config, String path, int defaultValue) return int config value with defaultstatic longgetLongWithDefault(com.typesafe.config.Config config, String path, long defaultValue) return long config value with defaultstatic NumbergetNumberWithDefault(com.typesafe.config.Config config, String path, Number defaultValue) return numeric config value with defaultgetStringList(com.typesafe.config.Config config, String path) return a String list config value where the value can be either a single String or String listgetStringMap(com.typesafe.config.Config config) return a String map config value where the key and value are both simpleStringstatic StringgetStringWithDefault(com.typesafe.config.Config config, String path, String defaultValue) return string config value with defaultstatic voidvalidateTimestampPattern(String fieldName, String fieldValue, String timestampPattern) Check if the input timestamp pattern is valid by invoking the DateTimeFormatter.static voidvalidateTimestampPatternWithEpoch(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.
-
Field Details
-
TIMESTAMP_FORMAT_EPOCH
- See Also:
-
TIMESTAMP_FORMAT_EPOCH_MILLIS
- See Also:
-
-
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 frompath- 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 frompath- 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 frompath- 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 frompath- 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 frompath- 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 frompath- path of the config value- Returns:
- config value
-
getStringMap
return a String map config value where the key and value are both simpleString- Parameters:
config- the typesafe config containing the String map- Returns:
- the map value
-
getChronoUnit
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 messagetimestampPattern- 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 messagetimestampPattern- The timestamp pattern string
-
getStringList
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 frompath- path of the config value- Returns:
- config value
-
getHoconString
Get the typesafeConfigValue.render()with given path- Parameters:
config- the typesafe object to read value frompath- the path- Returns:
Stringrepresentation for theConfigValue, and null if the path does not exist
-