Converts the specified value to
{@code com.google.appengine.api.datastore.Rating}.

@see org.apache.commons.beanutils.converters.AbstractConverter#convertToType(java.lang.Class, java.lang.Object)
432324
@SuppressWarnings("rawtypes")
	@Override
	protected Object convertToType(Class type, Object value) throws Throwable {
		try {
			return new Rating(Integer.parseInt(value.toString()));
		} catch (Exception e) {
			throw new ConversionException(
					"Cannot parse Rating value into integer [" + value + "]");
		}
	}
1203182
public <T> T toObject(Class<T> toClass, Class<? extends NumConverter> converterClass) {
		return (T) toObject(toClass, null, converterClass);
	}
400834
public Object convertResult(final Class<?> type) {
		try {
			if (type.isArray()) {
				return TYPE_MAP.get("array").invoke(this);
			}
			if (!TYPE_MAP.containsKey(type)) {
				return getNext(result);
			}
			return TYPE_MAP.get(type).invoke(this);
		} catch (final Exception e) {
			e.printStackTrace();
			return null;
		}
	}
1217982
public Object convert(Class<?> targetType, Object value) {
        if (value == null) {
            return null;
        }

        Converter converter = getConverter(value.getClass(), targetType);
        if (converter == null) {
            throw new IllegalArgumentException(
                    "No converter from " + value.getClass() + " to " + targetType.getName());
        } else {
            return converter.convert(targetType, value);
        }
    }
333745
public <T> T convert(Object value, Class<T> clazz) {
    if (null == value) return null;
    if (value instanceof String && Strings.isEmpty((String) value)) { return null; }
    if (value.getClass().isArray()) {
      Object[] values = (Object[]) value;
      if (values.length >= 1) {
        value = values[0];
      }
    }
    return conversion.convert(value, clazz);
  }
121790
public static ConversionType getConversionType(final Class<?> destination, final Class<?> source){
		
		if(destination == String.class)   return toStringConversion(source);
		if(destination == Byte.class)     return toByteConversion(source);
		if(destination == byte.class)     return tobyteConversion(source);
		if(destination == Short.class)    return toShortConversion(source);
		if(destination == short.class)    return toshortConversion(source);
		if(destination == Integer.class)  return toIntegerConversion(source);
		if(destination == int.class)      return tointConversion(source);
		if(destination == Long.class)     return toLongConversion(source);
		if(destination == long.class)     return tolongConversion(source);
		if(destination == Float.class)    return toFloatConversion(source);
		if(destination == float.class)    return tofloatConversion(source);
		if(destination == Double.class)   return toDoubleConversion(source);
		if(destination == double.class)   return todoubleConversion(source);
		if(destination == Character.class)return toCharacterConversion(source);
		if(destination == char.class)     return tocharConversion(source);
		if(destination == Boolean.class)  return toBooleanConversion(source);
		if(destination == boolean.class)  return tobooleanConversion(source);
		return UNDEFINED;
	}
1017938
public static Object convert(final Object value, Class<?> targetType, final String name) {
        if (value == null) {
            if (targetType.equals(Boolean.TYPE)) {
                return false;
            }
            return value;
        }

        final Class<? extends Object> actualType = value.getClass();

        if (targetType.isPrimitive()) {
            targetType =  PrimitiveTypes.valueOf(targetType.toString().toUpperCase()).getWraper();
        }

        if (targetType.isAssignableFrom(actualType)) {
            return value;
        }

        if (Number.class.isAssignableFrom(actualType) && Number.class.isAssignableFrom(targetType)) {
            return value;
        }

        if (!(value instanceof String)) {
            final String message = String.format("Expected type '%s' for '%s'. Found '%s'", targetType.getName(), name, actualType.getName());
            throw new IllegalArgumentException(message);
        }

        final String stringValue = (String) value;

        if (Enum.class.isAssignableFrom(targetType)) {
            final Class<? extends Enum> enumType = (Class<? extends Enum>) targetType;
            try {
                return Enum.valueOf(enumType, stringValue);
            } catch (final IllegalArgumentException e) {
                try {
                    return Enum.valueOf(enumType, stringValue.toUpperCase());
                } catch (final IllegalArgumentException e1) {
                    return Enum.valueOf(enumType, stringValue.toLowerCase());
                }
            }
        }

        try {
            // Force static initializers to run
            Class.forName(targetType.getName(), true, targetType.getClassLoader());
        } catch (final ClassNotFoundException e) {
            e.printStackTrace();
        }

        final PropertyEditor editor = Editors.get(targetType);

        if (editor == null) {
            final Object result = create(targetType, stringValue);
            if (result != null) {
                return result;
            }
        }

        if (editor == null) {
            final String message = String.format("Cannot convert to '%s' for '%s'. No PropertyEditor", targetType.getName(), name);
            throw new IllegalArgumentException(message);
        }

        editor.setAsText(stringValue);
        return editor.getValue();
    }
1303210
@SuppressWarnings({ "unchecked", "rawtypes" })
    public static Object convert(Object source, Class<?> target) throws ConversionException {
        if (target == null) {
            throw new ConversionException("Unable to perform conversion, target was null");
        }
        if (source == null) {
            if (target.isPrimitive()) {
                throw new ConversionException(String.format("Unable to convert null to primitive value of %s", target));
            }
            return source;
        } else if ((source instanceof Float && ((Float) source).isNaN()) || (source instanceof Double && ((Double) source).isNaN())) {
            // Don't convert NaN values
            return source;
        }
        //		if (BaseConnection.class.isAssignableFrom(source.getClass()) && !target.equals(IConnection.class)) {
        //			log.debug("Conversion failure - source: {} target: {}", source.getClass(), target);
        //			throw new ConversionException("Source is not assignable and target is not equal to IConnection");
        //		}
        if (target.isInstance(source)) {
            return source;
        }
        if (target.isAssignableFrom(source.getClass())) {
            return source;
        }
        if (target.isArray()) {
            return convertToArray(source, target);
        }
        if (target.equals(String.class)) {
            return source.toString();
        }
        if (target.isPrimitive()) {
            return convertToWrappedPrimitive(source, primitiveMap.get(target));
        }
        if (wrapperMap.containsKey(target)) {
            return convertToWrappedPrimitive(source, target);
        }
        if (target.equals(Map.class)) {
            return convertBeanToMap(source);
        }
        if (target.equals(List.class) || target.equals(Collection.class)) {
            if (source.getClass().equals(LinkedHashMap.class)) {
                return convertMapToList((LinkedHashMap<?, ?>) source);
            } else if (source.getClass().isArray()) {
                return convertArrayToList((Object[]) source);
            }
        }
        if (target.equals(Set.class) && source.getClass().isArray()) {
            return convertArrayToSet((Object[]) source);
        }
        if (target.equals(Set.class) && source instanceof List) {
            return new HashSet((List) source);
        }
        if (source instanceof Map) {
            return convertMapToBean((Map) source, target);
        }
        throw new ConversionException(String.format("Unable to preform conversion from %s to %s", source, target));
    }
1053169
public <T> T convert(ConversionContext context, Object source,
			Class<T> clazz) throws ConverterException {
		return (T) convert(context, source, TypeReference.get(clazz));
	}
662466
protected static Object convertBasicValue(String value, Class<?> type) {
        if (type == null) {
            throw new IllegalArgumentException("Type cannot be null");
        }

        if (String.class.equals(type)) {
            return value;
        }

        if (value == null || value.trim().isEmpty()) {
            return null;
        }

        try {
            value = value.trim();
            if (Byte.class.equals(type)) {
                return Byte.parseByte(value);
            } else if (Short.class.equals(type)) {
                return Short.parseShort(value);
            } else if (Integer.class.equals(type)) {
                return Integer.parseInt(value);
            } else if (Long.class.equals(type)) {
                return Long.parseLong(value);
            } else if (BigInteger.class.equals(type)) {
                return new BigInteger(value);
            } else if (Float.class.equals(type)) {
                return Float.parseFloat(value);
            } else if (Double.class.equals(type)) {
                return Double.parseDouble(value);
            } else if (BigDecimal.class.equals(type)) {
                return new BigDecimal(value);
            } else if (Boolean.class.equals(type)) {
                return Boolean.parseBoolean(value);
            }
        } catch (Exception e) {
            throw new UniformException(String.format("Error while converting value %s to data type %s. Make sure the element has correct values and/or validators", value, type.getName()), e);
        }

        throw new UnsupportedOperationException("Could not convert value to unknown type: " + type.getName());
    }
370886
private static Object toPrimitive(final String value, final Class<?> type) {

        final Class<?> objectType = objectTypeFor(type);
        final Object objectValue = valueOf(value, objectType);
        final Object primitiveValue;

        final String toValueMethodName = type.getSimpleName() + "Value";
        try {
            final Method toValueMethod = objectType.getMethod(toValueMethodName);
            primitiveValue = toValueMethod.invoke(objectValue);
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
            //this should never happen
            throw new RuntimeException("Can not convert to primitive type", e); //NOSONAR
        }

        return primitiveValue;
    }
1207845
public static <T> T convert(TypeReference<T> reference, Object value) throws ConvertException{
		return convert(reference.getType(), value, null);
	}
758935
public static Object convert(String dataType, Object record){
		if(record == null){return null;}
		if(dataType.equals(UUID)){
			return java.util.UUID.fromString(record.toString());
		}
		//TODO: add a lot of else if here for the other data types
		else{
			return record;
		}
	}
482595
public static Object convertValue(final Object value, final Class<?> convertType) {
        if (null == value) {
            return convertNullValue(convertType);
        } 
        if (value.getClass() == convertType) {
            return value;
        }
        if (value instanceof Number) {
            return convertNumberValue(value, convertType);
        }
        if (value instanceof Date) {
            return convertDateValue(value, convertType);
        }
        if (String.class.equals(convertType)) {
            return value.toString();
        } else {
            return value;
        }
    }
1036624
private Class<?> convertType(Class<?> old)
   {
      if (Boolean.class.equals(old))
      {
         return boolean.class;
      }
      else if (boolean.class.equals(old))
      {
         return Boolean.class;
      }
      else if (Byte.class.equals(old))
      {
         return byte.class;
      }
      else if (byte.class.equals(old))
      {
         return Byte.class;
      }
      else if (Short.class.equals(old))
      {
         return short.class;
      }
      else if (short.class.equals(old))
      {
         return Short.class;
      }
      else if (Integer.class.equals(old))
      {
         return int.class;
      }
      else if (int.class.equals(old))
      {
         return Integer.class;
      }
      else if (Long.class.equals(old))
      {
         return long.class;
      }
      else if (long.class.equals(old))
      {
         return Long.class;
      }
      else if (Float.class.equals(old))
      {
         return float.class;
      }
      else if (float.class.equals(old))
      {
         return Float.class;
      }
      else if (Double.class.equals(old))
      {
         return double.class;
      }
      else if (double.class.equals(old))
      {
         return Double.class;
      }
      else if (Character.class.equals(old))
      {
         return char.class;
      }
      else if (char.class.equals(old))
      {
         return Character.class;
      }

      return null;
   }
1155850
@Deprecated
	public static Object convert(final Class<?> clazz, String val)
	{
		return StringToTypeConverter.convert(clazz, val);
	}
362105
public static Map<String, Object> convert(Object pojo,
                                              Class<? extends Annotation> annotationType) {
        return convert(pojo, annotationType, true);
    }