Exemple #1
0
  /**
   * Casts the specified value to Float data type.
   *
   * @see DataType#FLOAT
   */
  private static Float toFloat(Object value) {

    if (value instanceof Float) {
      return (Float) value;
    } else if (value instanceof Integer) {
      Number number = (Number) value;

      return Float.valueOf(number.floatValue());
    }

    throw new TypeCheckException(DataType.FLOAT, value);
  }
Exemple #2
0
  /**
   * Casts the specified value to Double data type.
   *
   * @see DataType#DOUBLE
   */
  private static Double toDouble(Object value) {

    if (value instanceof Double) {
      return (Double) value;
    } else if ((value instanceof Float) || (value instanceof Integer)) {
      Number number = (Number) value;

      return Double.valueOf(number.doubleValue());
    }

    throw new TypeCheckException(DataType.DOUBLE, value);
  }
Exemple #3
0
  /**
   * Casts the specified value to String data type.
   *
   * @see DataType#STRING
   */
  private static String toString(Object value) {

    if (value instanceof String) {
      return (String) value;
    } else if ((value instanceof Double)
        || (value instanceof Float)
        || (value instanceof Integer)) {
      Number number = (Number) value;

      return number.toString();
    }

    throw new TypeCheckException(DataType.STRING, value);
  }