docs: @SuppressWarnings("unchecked")
  	public static <T> T toNullableType(Class<T> type, Object value) {
  		TypeCode resultType = toTypeCode(type);
  
  		if (value == null)
  			return null;
  		if (type.isInstance(value))
  			return (T) value;
  
  		// Convert to known types
  		if (resultType == TypeCode.String)
  			return type.cast(StringConverter.toNullableString(value));
  		else if (resultType == TypeCode.Integer)
  			return type.cast(IntegerConverter.toNullableInteger(value));
  		else if (resultType == TypeCode.Long)
  			return type.cast(LongConverter.toNullableLong(value));
  		else if (resultType == TypeCode.Float)
  			return type.cast(FloatConverter.toNullableFloat(value));
  		else if (resultType == TypeCode.Double)
  			return type.cast(DoubleConverter.toNullableDouble(value));
  		else if (resultType == TypeCode.Duration)
  			return type.cast(DurationConverter.toNullableDuration(value));
  		else if (resultType == TypeCode.DateTime)
  			return type.cast(DateTimeConverter.toNullableDateTime(value));
  		else if (resultType == TypeCode.Array)
  			return type.cast(ArrayConverter.toNullableArray(value));
  		else if (resultType == TypeCode.Map)
  			return type.cast(MapConverter.toNullableMap(value));
  
  		// Convert to unknown type
  		try {
  			return type.cast(value);
  		} catch (Throwable t) {
  			return null;
  		}
  	}