Class ConfigurationUtils

java.lang.Object
org.jmxtrans.agent.util.ConfigurationUtils

public class ConfigurationUtils
extends Object
Author:
Cyrille Le Clerc
  • Method Details

    • getInt

      public static int getInt​(Map<String,​String> settings, String name) throws IllegalArgumentException
      Convert 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 IllegalArgumentException
      Convert value of this setting to a Java int. If the property is not found, the defaultValue is returned. If the property is not an int, an exception is thrown.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      int value of the property or defaultValue if 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 IllegalArgumentException
      Convert value of this setting to a Java long. If the property is not found, the defaultValue is returned. If the property is not a long, an exception is thrown.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      int value of the property or defaultValue if the property is not defined.
      Throws:
      IllegalArgumentException - if setting is not is not a long.
    • getBoolean

      public static boolean getBoolean​(Map<String,​String> settings, String name, boolean defaultValue)
      Convert value of this setting to a Java boolean (via Boolean.parseBoolean(String)). If the property is not found, the defaultValue is returned.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      int value of the property or defaultValue if the property is not defined.
    • getString

      public static String getString​(Map<String,​String> settings, String name) throws IllegalArgumentException
      Convert 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

      public static String getString​(Map<String,​String> settings, String name, String defaultValue)
      Return the value of the given property. If the property is not found, the defaultValue is returned.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      value of the property or defaultValue if the property is not defined.