use of org.apache.cxf.jaxrs.model.ParameterType in project cxf by apache.
the class InjectionUtils method injectIntoCollectionOrArray.
// CHECKSTYLE:OFF
private static Object injectIntoCollectionOrArray(Class<?> rawType, Type genericType, Annotation[] paramAnns, MultivaluedMap<String, String> values, boolean isbean, boolean decoded, ParameterType pathParam, Message message) {
// CHECKSTYLE:ON
Class<?> type = getCollectionType(rawType);
final Class<?> realType;
final Type realGenericType;
if (rawType.isArray()) {
realType = rawType.getComponentType();
realGenericType = realType;
} else {
Type[] types = getActualTypes(genericType);
if (types == null || types.length == 0 || !(types[0] instanceof ParameterizedType)) {
realType = getActualType(genericType);
realGenericType = realType;
} else {
realType = getRawType(types[0]);
realGenericType = types[0];
}
}
Object theValues = null;
if (type != null) {
try {
theValues = type.newInstance();
} catch (IllegalAccessException ex) {
reportServerError("CLASS_ACCESS_FAILURE", type.getName());
} catch (Exception ex) {
reportServerError("CLASS_INSTANTIATION_FAILURE", type.getName());
}
} else {
theValues = Array.newInstance(realType, isbean ? 1 : values.values().iterator().next().size());
}
if (isbean) {
Object o = InjectionUtils.handleBean(realType, paramAnns, values, pathParam, message, decoded);
addToCollectionValues(theValues, o, 0);
} else {
List<String> valuesList = values.values().iterator().next();
valuesList = checkPathSegment(valuesList, realType, pathParam);
for (int ind = 0; ind < valuesList.size(); ind++) {
Object o = InjectionUtils.handleParameter(valuesList.get(ind), decoded, realType, realGenericType, paramAnns, pathParam, message);
addToCollectionValues(theValues, o, ind);
}
}
return theValues;
}
Aggregations