private void checkForFields(TableObject tableObject, Element columnElement) {
Field fieldAnnotation = columnElement.getAnnotation(Field.class);
if (fieldAnnotation == null) return;
/* Convert the element from a field to a type */
final Element typeElement = typeUtils.asElement(columnElement.asType());
final String type = typeElement == null ? columnElement.asType().toString()
: elementUtils.getBinaryName((TypeElement) typeElement).toString();
TableColumn tableColumn = new TableColumn(columnElement, type);
if (tableColumn.isBlob() && !tableColumn.isByteArray()) {
if (!checkForSuperType(columnElement, Serializable.class)
&& !columnElement.asType().toString().equals("java.lang.Byte[]")) {
logger.e(String.format(
"%s in %s is not Serializable and will not be able to be converted to a byte array",
columnElement.toString(), tableObject.getTableName()));
}
} else if (tableColumn.isOneToMany()) {
// List<T> should only have one generic type. Get that type and make sure
// it has @Table annotation
TypeMirror typeMirror = ((DeclaredType) columnElement.asType()).getTypeArguments().get(0);
if (typeUtils.asElement(typeMirror).getAnnotation(Table.class) == null) {
logger.e("One to many relationship in class %s where %s is not annotated with @Table",
tableObject.getTableName(), tableColumn.getColumnName());
}
oneToManyCache.put(typeMirror.toString(), tableObject);
TypeElement childColumnElement = elementUtils.getTypeElement(typeMirror.toString());
tableColumn.setType(getClassName(childColumnElement, getPackageName(childColumnElement)));
} else if (tableColumn.getSqlType() == SqliteType.UNKNOWN) {
@SuppressWarnings("ConstantConditions")
Table annotation = typeElement.getAnnotation(Table.class);
if (annotation == null) {
logger.e(String.format("%s in %s needs to be marked as a blob or should be "
+ "annotated with @Table", columnElement.toString(), tableObject.getTableName()));
}
tableColumn.setOneToOne(true);