List of usage examples for java.lang.reflect Field toGenericString
public String toGenericString()
From source file:ca.oson.json.Oson.java
private <T> Object getParameterValue(Map<String, Object> map, Class<T> valueType, String parameterName, Class parameterType) {//from w w w . ja v a2 s . co m Object parameterValue = getMapValue(map, parameterName); Class fieldType = null; if (Map.class.isAssignableFrom(parameterType)) { // just give the whole map data to it // it can use as much of it as it likes parameterValue = map; } else { if (parameterType.isPrimitive() || Number.class.isAssignableFrom(parameterType) || parameterType == String.class || parameterType == Character.class || parameterType == Boolean.class || Date.class.isAssignableFrom(parameterType) || parameterType.isEnum() || Enum.class.isAssignableFrom(parameterType)) { // do nothing } else { String toGenericString = parameterType.toGenericString(); fieldType = ObjectUtil.getComponentType(toGenericString); if (fieldType == null) { Field[] fields = getFields(valueType); for (Field field : fields) { if (field.getName().equalsIgnoreCase(parameterName)) { // private java.util.List<ca.oson.json.domain.Address> ca.oson.json.domain.Person.addressList toGenericString = field.toGenericString(); // fieldType = field.getType(); // getClass(); fieldType = ObjectUtil.getComponentType(toGenericString); break; } } } } FieldData objectDTO = null; if (fieldType != null) { // FieldData(Object valueToProcess, Type type, boolean json2Java) ComponentType componentType = new ComponentType(parameterType, fieldType); cachedComponentTypes(componentType); objectDTO = new FieldData(parameterValue, parameterType, true); objectDTO.componentType = componentType; } else { objectDTO = new FieldData(parameterValue, parameterType, true); } objectDTO.required = true; parameterValue = json2Object(objectDTO); } return parameterValue; }