* @param <T>
* a T object.
* @return a {@link javax.ws.rs.core.MultivaluedMap} object.
*/
public static <T> MultivaluedMap<String, String> getBodyAsMultiValuedMap(Request<T> request) {
MultivaluedMap<String, String> map = new BodyMultivaluedMap();
Class<?> referenceClazz = request.getClass();
List<Field> fields = ClassUtil.getAnnotatedFields(referenceClazz, Body.class);
for (Field field : fields) {
Body body = field.getAnnotation(Body.class);
String parameter = body.value();
// in case the value() is null or empty
if (parameter == null || (parameter != null && parameter.isEmpty())) {
parameter = field.getName();
}
String value = ClassUtil.getValueOf(field, request, referenceClazz, String.class);
map.putSingle(parameter, value);
}
return map;
}