use of com.bluelinelabs.logansquare.annotation.JsonField in project LoganSquare by bluelinelabs.
the class JsonFieldProcessor method processJsonFieldAnnotation.
private void processJsonFieldAnnotation(Element element, Map<String, JsonObjectHolder> jsonObjectMap, Elements elements, Types types) {
if (!isJsonFieldFieldAnnotationValid(element, elements)) {
return;
}
TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();
JsonObjectHolder objectHolder = jsonObjectMap.get(TypeUtils.getInjectedFQCN(enclosingElement, elements));
JsonFieldHolder fieldHolder = objectHolder.fieldMap.get(element.getSimpleName().toString());
if (fieldHolder == null) {
fieldHolder = new JsonFieldHolder();
objectHolder.fieldMap.put(element.getSimpleName().toString(), fieldHolder);
}
JsonField annotation = element.getAnnotation(JsonField.class);
TypeMirror typeConverterType;
try {
typeConverterType = mProcessingEnv.getElementUtils().getTypeElement(annotation.typeConverter().getCanonicalName()).asType();
} catch (MirroredTypeException mte) {
typeConverterType = mte.getTypeMirror();
}
String[] fieldName = annotation.name();
JsonIgnore ignoreAnnotation = element.getAnnotation(JsonIgnore.class);
boolean shouldParse = ignoreAnnotation == null || ignoreAnnotation.ignorePolicy() == IgnorePolicy.SERIALIZE_ONLY;
boolean shouldSerialize = ignoreAnnotation == null || ignoreAnnotation.ignorePolicy() == IgnorePolicy.PARSE_ONLY;
String error = fieldHolder.fill(element, elements, types, fieldName, typeConverterType, objectHolder, shouldParse, shouldSerialize);
if (!TextUtils.isEmpty(error)) {
error(element, error);
}
ensureTypeConverterClassValid(typeConverterType, elements, types);
}
Aggregations