Package ej.bon

## Class Constants

- java.lang.Object
- - ej.bon.Constants

-     public class Constants
      extends Object

  This class provides access to compile-time constants. A constant is retrieved from its name, and is replaced by its value using the desired `getXXX` method depending on the expected type.

  The constant name must be resolved by the compiler as a String literal at the location where the `getXXX` method is called. Constant Expressions are specified in section `15.28 Constant Expressions` of the Java Language Specification.

  The following usages are allowed:

       // Name is a String Literal
       boolean value = Constants.getBoolean("MyConstant")

       // Name is a Field Access to a static final field declaration
       // of type String, and initialized with a Constant Expression
       static final String MY_CONSTANT = "My" + "Constant";
       boolean value = Constants.getBoolean(MY_CONSTANT)

  The following usages are not allowed:

       // Name is a String Object
       boolean value = Constants.getBoolean(new String("MyConstant"))

       // Name is a Field Access to a static final field declaration
       // of type String, but not initialized with a Constant Expression
       static final String MY_CONSTANT = getMyConstantName();
       boolean value = Constants.getBoolean(MY_CONSTANT)

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Constants()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static boolean` | `getBoolean​(String name)` | Gets a `boolean` constant.
    `static byte` | `getByte​(String name)` | Gets a `byte` constant.
    `static char` | `getChar​(String name)` | Gets a `char` constant.
    `static Class<?>` | `getClass​(String name)` | Gets a `Class` constant.
    `static double` | `getDouble​(String name)` | Gets a `double` constant.
    `static float` | `getFloat​(String name)` | Gets a `float` constant.
    `static int` | `getInt​(String name)` | Gets an `int` constant.
    `static long` | `getLong​(String name)` | Gets a `long` constant.
    `static short` | `getShort​(String name)` | Gets a `short` constant.
    `static String` | `getString​(String name)` | Gets a `String` constant.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Constants

          public Constants()

  - ### Method Detail

    - #### getBoolean

          public static boolean getBoolean​(String name)

      Gets a `boolean` constant.

      The constant is resolved to `true` if its value is equals to `"true"`, `false` if its value is equals to `"false"`.

      Parameters:
        `name` - the constant name
      Returns:
        the boolean constant

    - #### getByte

          public static byte getByte​(String name)

      Gets a `byte` constant.

      The constant is resolved to a `byte` if its value is resolved to an `int` included into the range `[-128,127]`.

      Parameters:
        `name` - the constant name
      Returns:
        the byte constant
      See Also:
        `getInt(String)`

    - #### getChar

          public static char getChar​(String name)

      Gets a `char` constant.

      The constant is resolved to a `char` if its value is resolved to an `int` included into the range `[0,65535]`.

      Parameters:
        `name` - the constant name
      Returns:
        the char constant
      See Also:
        `getInt(String)`

    - #### getShort

          public static short getShort​(String name)

      Gets a `short` constant.

      The constant is resolved to a `short` if its value is resolved to an `int` included into the range `[-32768,32767]`.

      Parameters:
        `name` - the constant name
      Returns:
        the short constant
      See Also:
        `getInt(String)`

    - #### getInt

          public static int getInt​(String name)

      Gets an `int` constant.

      The constant is resolved to an `int` if its `String` value:

      - is a valid argument for `Integer.decode(String)`
      - is an unsigned integer written in hexadecimal format such as `0xFFFFFFFF`. In this latter case, the constant is resolved to `-1`.
      Parameters:
        `name` - the constant name
      Returns:
        the int constant

    - #### getLong

          public static long getLong​(String name)

      Gets a `long` constant.

      The constant is resolved to a `long` if its `String` value:

      - is a valid argument for `Long.decode(String)`
      - if an unsigned long written in hexadecimal format such as `0xFFFFFFFFFFFFFFFF`. In this latter case, the constant is resolved to `-1`.
      Parameters:
        `name` - the constant name
      Returns:
        the long constant

    - #### getFloat

          public static float getFloat​(String name)

      Gets a `float` constant.

      The constant is resolved to a `float` if its value can be loaded by `Float.valueOf(String)`.

      Parameters:
        `name` - the constant name
      Returns:
        the float constant

    - #### getDouble

          public static double getDouble​(String name)

      Gets a `double` constant.

      The constant is resolved to a `double` if its value can be loaded by `Double.valueOf(String)`.

      Parameters:
        `name` - the constant name
      Returns:
        the short constant

    - #### getString

          public static String getString​(String name)

      Gets a `String` constant.
      Parameters:
        `name` - the constant name
      Returns:
        the String constant

    - #### getClass

          public static Class<?> getClass​(String name)

      Gets a `Class` constant.

      The constant is resolved to a `Class` if its value describes the fully qualified name of a `Class` that can be loaded from the classpath.

      Parameters:
        `name` - the constant name
      Returns:
        the `Class` constant