use of com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn in project storio by pushtorefresh.
the class StorIOSQLiteProcessor method processAnnotatedFieldOrMethod.
/**
* Processes annotated field and returns result of processing or throws exception.
*
* @param annotatedField field that was annotated with {@link StorIOSQLiteColumn}
* @return non-null {@link StorIOSQLiteColumnMeta} with meta information about field
*/
@NotNull
@Override
protected StorIOSQLiteColumnMeta 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 " + StorIOSQLiteColumn.class.getSimpleName() + " annotation, if you need to serialize/deserialize field of that type " + "-> please write your own resolver: " + e.getMessage());
}
final StorIOSQLiteColumn storIOSQLiteColumn = annotatedField.getAnnotation(StorIOSQLiteColumn.class);
if (storIOSQLiteColumn.ignoreNull() && annotatedField.asType().getKind().isPrimitive()) {
throw new ProcessingException(annotatedField, "ignoreNull should not be used for primitive type: " + annotatedField.getSimpleName());
}
final String columnName = storIOSQLiteColumn.name();
if (columnName.length() == 0) {
throw new ProcessingException(annotatedField, "Column name is empty: " + annotatedField.getSimpleName());
}
return new StorIOSQLiteColumnMeta(annotatedField.getEnclosingElement(), annotatedField, annotatedField.getSimpleName().toString(), javaType, storIOSQLiteColumn);
}
Aggregations