return "valuemap";
}
public Object getValue(Object adaptable, String name, Type type, AnnotatedElement element,
DisposalCallbackRegistry callbackRegistry) {
ValueMap map = getValueMap(adaptable);
if (map == null) {
return null;
} else if (type instanceof Class<?>) {
Class<?> clazz = (Class<?>) type;
try {
return map.get(name, clazz);
} catch (ClassCastException e) {
// handle case of primitive/wrapper arrays
if (clazz.isArray()) {
Class<?> componentType = clazz.getComponentType();
if (componentType.isPrimitive()) {
Class<?> wrapper = ClassUtils.primitiveToWrapper(componentType);
if (wrapper != componentType) {
Object wrapperArray = map.get(name, Array.newInstance(wrapper, 0).getClass());
if (wrapperArray != null) {
return unwrapArray(wrapperArray, componentType);
}
}
} else {
Class<?> primitiveType = ClassUtils.wrapperToPrimitive(componentType);
if (primitiveType != componentType) {
Object primitiveArray = map.get(name, Array.newInstance(primitiveType, 0).getClass());
if (primitiveArray != null) {
return wrapArray(primitiveArray, componentType);
}
}
}
}
return null;
}
} else if (type instanceof ParameterizedType) {
// list support
ParameterizedType pType = (ParameterizedType) type;
if (pType.getActualTypeArguments().length != 1) {
return null;
}
Class<?> collectionType = (Class<?>) pType.getRawType();
if (!(collectionType.equals(Collection.class) || collectionType.equals(List.class))) {
return null;
}
Class<?> itemType = (Class<?>) pType.getActualTypeArguments()[0];
Object array = map.get(name, Array.newInstance(itemType, 0).getClass());
if (array == null) {
return null;
}