Beispiel #1
0
  /**
   * Get a double-precision (64-bit) floating point number (double) parameter.
   *
   * @param key the key identifying the parameter
   * @param min the minimum allowed value, a {@link java.lang.IllegalArgumentException
   *     IllegalArgumentException} will be thrown if this constraint is violated
   * @param max the maximum allowed value, a {@link java.lang.IllegalArgumentException
   *     IllegalArgumentException} will be thrown if this constraint is violated
   * @param def the default value
   * @return the parameter value, a double parsed from the configuration data
   */
  public final double getDouble(
      final String key, final double min, final double max, final double def) {
    final String k;
    final Object v;
    final java.lang.Number number;

    k = Configuration.__checkKey(key);

    synchronized (this.m_data) {
      v = this.m_data.get(k);

      if (v == null) {
        return def;
      }

      number = new DoubleParser(min, max).parse(v);

      if (number != v) {
        this.m_data.put(key, v);
      }
    }

    return number.doubleValue();
  }