Package org.jmxtrans.agent.util
Class ConfigurationUtils
java.lang.Object
org.jmxtrans.agent.util.ConfigurationUtils
public class ConfigurationUtils extends Object
- Author:
- Cyrille Le Clerc
-
Method Summary
Modifier and Type Method Description static booleangetBoolean(Map<String,String> settings, String name, boolean defaultValue)Convert value of this setting to a Java boolean (viaBoolean.parseBoolean(String)).static intgetInt(Map<String,String> settings, String name)Convert value of this setting to a Java int.static intgetInt(Map<String,String> settings, String name, int defaultValue)Convert value of this setting to a Java int.static longgetLong(Map<String,String> settings, String name, long defaultValue)Convert value of this setting to a Java long.static StringgetString(Map<String,String> settings, String name)Convert value of this setting to a Java int.static StringgetString(Map<String,String> settings, String name, String defaultValue)Return the value of the given property.
-
Method Details
-
getInt
public static int getInt(Map<String,String> settings, String name) throws IllegalArgumentExceptionConvert value of this setting to a Java int. If the setting is not found or is not an int, an exception is thrown.- Parameters:
name- name of the setting / property- Returns:
- int value of the setting / property
- Throws:
IllegalArgumentException- if setting is not found or is not an integer.
-
getInt
public static int getInt(Map<String,String> settings, String name, int defaultValue) throws IllegalArgumentExceptionConvert value of this setting to a Java int. If the property is not found, thedefaultValueis returned. If the property is not an int, an exception is thrown.- Parameters:
name- name of the propertydefaultValue- default value if the property is not defined.- Returns:
- int value of the property or
defaultValueif the property is not defined. - Throws:
IllegalArgumentException- if setting is not is not an integer.
-
getLong
public static long getLong(Map<String,String> settings, String name, long defaultValue) throws IllegalArgumentExceptionConvert value of this setting to a Java long. If the property is not found, thedefaultValueis returned. If the property is not a long, an exception is thrown.- Parameters:
name- name of the propertydefaultValue- default value if the property is not defined.- Returns:
- int value of the property or
defaultValueif the property is not defined. - Throws:
IllegalArgumentException- if setting is not is not a long.
-
getBoolean
Convert value of this setting to a Java boolean (viaBoolean.parseBoolean(String)). If the property is not found, thedefaultValueis returned.- Parameters:
name- name of the propertydefaultValue- default value if the property is not defined.- Returns:
- int value of the property or
defaultValueif the property is not defined.
-
getString
public static String getString(Map<String,String> settings, String name) throws IllegalArgumentExceptionConvert value of this setting to a Java int. If the setting is not found, an exception is thrown.- Parameters:
name- name of the property- Returns:
- value of the property
- Throws:
IllegalArgumentException- if setting is not found.
-
getString
Return the value of the given property. If the property is not found, thedefaultValueis returned.- Parameters:
name- name of the propertydefaultValue- default value if the property is not defined.- Returns:
- value of the property or
defaultValueif the property is not defined.
-