use of com.google.gson.annotations.SerializedName in project cloudstack by apache.
the class ApiDiscoveryServiceImpl method getFieldResponseMap.
private ApiResponseResponse getFieldResponseMap(Field responseField) {
ApiResponseResponse responseResponse = new ApiResponseResponse();
SerializedName serializedName = responseField.getAnnotation(SerializedName.class);
Param param = responseField.getAnnotation(Param.class);
if (serializedName != null && param != null) {
responseResponse.setName(serializedName.value());
responseResponse.setDescription(param.description());
responseResponse.setType(responseField.getType().getSimpleName().toLowerCase());
// If response is not of primitive type - we have a nested entity
Class fieldClass = param.responseObject();
if (fieldClass != null) {
Class<?> superClass = fieldClass.getSuperclass();
if (superClass != null) {
String superName = superClass.getName();
if (superName.equals(BaseResponse.class.getName())) {
Field[] fields = fieldClass.getDeclaredFields();
for (Field field : fields) {
ApiResponseResponse innerResponse = getFieldResponseMap(field);
if (innerResponse != null) {
responseResponse.addApiResponse(innerResponse);
}
}
}
}
}
}
return responseResponse;
}
Aggregations