Package org.apache.flink.util
Class PropertiesUtil
- java.lang.Object
-
- org.apache.flink.util.PropertiesUtil
-
public class PropertiesUtil extends Object
Simple utilities for getting typed values from Properties.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Properties
flatten(Properties config)
Flatten a recursiveProperties
to a first level property map.static boolean
getBoolean(Properties config, String key, boolean defaultValue)
Get boolean from properties.static int
getInt(Properties config, String key, int defaultValue)
Get integer from properties.static long
getLong(Properties config, String key, long defaultValue)
Get long from properties.static long
getLong(Properties config, String key, long defaultValue, org.slf4j.Logger logger)
Get long from properties.
-
-
-
Method Detail
-
getInt
public static int getInt(Properties config, String key, int defaultValue)
Get integer from properties. This method throws an exception if the integer is not valid.- Parameters:
config
- Propertieskey
- key in PropertiesdefaultValue
- default value if value is not set- Returns:
- default or value of key
-
getLong
public static long getLong(Properties config, String key, long defaultValue)
Get long from properties. This method throws an exception if the long is not valid.- Parameters:
config
- Propertieskey
- key in PropertiesdefaultValue
- default value if value is not set- Returns:
- default or value of key
-
getLong
public static long getLong(Properties config, String key, long defaultValue, org.slf4j.Logger logger)
Get long from properties. This method only logs if the long is not valid.- Parameters:
config
- Propertieskey
- key in PropertiesdefaultValue
- default value if value is not set- Returns:
- default or value of key
-
getBoolean
public static boolean getBoolean(Properties config, String key, boolean defaultValue)
Get boolean from properties. This method returnstrue
iff the parsed value is "true".- Parameters:
config
- Propertieskey
- key in PropertiesdefaultValue
- default value if value is not set- Returns:
- default or value of key
-
flatten
public static Properties flatten(Properties config)
Flatten a recursiveProperties
to a first level property map.In some cases,
KafkaProducer#propsToMap
for example, Properties is used purely as a HashTable without considering its default properties.- Parameters:
config
- Properties to be flattened- Returns:
- Properties without defaults; all properties are put in the first-level
-
-