@SuppressWarnings("unchecked")
  public static <T> T _convertObjectIntoCompatibleValue(Object value, Class<T> newValueType) {
    if (value == null || newValueType == value.getClass())
      return (T)value;
    if (newValueType == String.class)
      return (T)value.toString();
    if (_NSUtilities._isClassANumber(newValueType)) {
      if (value instanceof Number)
        return (T) _NSUtilities.convertNumberIntoCompatibleValue((Number)value, (Class<Number>)newValueType);
      if (value instanceof Boolean)
        return (T) _NSUtilities.convertNumberIntoCompatibleValue(_NSUtilities.convertBooleanIntoNumberValue((Boolean)value), (Class<Number>)newValueType);
      return (T) _NSUtilities.convertNumberIntoCompatibleValue(new Double(value.toString()), (Class<Number>)newValueType);
    }
    if (_NSUtilities._isClassABoolean(newValueType)) {
      if (value instanceof Number)
        return (T) _NSUtilities.convertNumberIntoBooleanValue((Number)value);
      return (T) Boolean.valueOf(value.toString());
    }
    return (T) value;
  }