use of com.pushtorefresh.storio.contentresolver.annotations.StorIOContentResolverColumn in project storio by pushtorefresh.
the class StorIOContentResolverProcessor method processAnnotatedFieldOrMethod.
/**
* Processes annotated field and returns result of processing or throws exception
*
* @param annotatedField field that was annotated with {@link StorIOContentResolverColumn}
* @return non-null {@link StorIOContentResolverColumnMeta} with meta information about field
*/
@NotNull
@Override
protected StorIOContentResolverColumnMeta processAnnotatedFieldOrMethod(@NotNull final Element annotatedField) {
final JavaType javaType;
try {
javaType = JavaType.from(annotatedField.getKind() == ElementKind.FIELD ? annotatedField.asType() : ((ExecutableElement) annotatedField).getReturnType());
} catch (Exception e) {
throw new ProcessingException(annotatedField, "Unsupported type of field or method for " + StorIOContentResolverColumn.class.getSimpleName() + " annotation, if you need to serialize/deserialize field of that type " + "-> please write your own resolver: " + e.getMessage());
}
final StorIOContentResolverColumn storIOContentResolverColumn = annotatedField.getAnnotation(StorIOContentResolverColumn.class);
if (storIOContentResolverColumn.ignoreNull() && annotatedField.asType().getKind().isPrimitive()) {
throw new ProcessingException(annotatedField, "ignoreNull should not be used for primitive type: " + annotatedField.getSimpleName());
}
final String columnName = storIOContentResolverColumn.name();
if (columnName.length() == 0) {
throw new ProcessingException(annotatedField, "Column name is empty: " + annotatedField.getSimpleName());
}
return new StorIOContentResolverColumnMeta(annotatedField.getEnclosingElement(), annotatedField, annotatedField.getSimpleName().toString(), javaType, storIOContentResolverColumn);
}
Aggregations