if (identifier.getFieldType().equals(DATE)) {
setDateAnnotations(identifier.getColumnDefinition(),
annotations);
}
final FieldMetadata idField = new FieldMetadataBuilder(getId(),
Modifier.PRIVATE, annotations,
identifier.getFieldName(), identifier.getFieldType())
.build();
// Only add field to ITD if not declared on governor
if (!hasField(declaredFields, idField)) {
fields.add(idField);
}
}
}
fields.addAll(declaredFields);
// Remove fields with static and transient modifiers
for (final Iterator<FieldMetadata> iter = fields.iterator(); iter
.hasNext();) {
final FieldMetadata field = iter.next();
if (Modifier.isStatic(field.getModifier())
|| Modifier.isTransient(field.getModifier())) {
iter.remove();
}
}
// Remove fields with the @Transient annotation
final List<FieldMetadata> transientAnnotatedFields = governorTypeDetails
.getFieldsWithAnnotation(TRANSIENT);
if (fields.containsAll(transientAnnotatedFields)) {
fields.removeAll(transientAnnotatedFields);
}
final List<FieldMetadataBuilder> fieldBuilders = new ArrayList<FieldMetadataBuilder>();
if (!fields.isEmpty()) {
for (final FieldMetadata field : fields) {
fieldBuilders.add(new FieldMetadataBuilder(field));
}
return fieldBuilders;
}
// We need to create a default identifier field
final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
// Compute the column name, as required
final AnnotationMetadataBuilder columnBuilder = new AnnotationMetadataBuilder(
COLUMN);
columnBuilder.addStringAttribute("name", "id");
columnBuilder.addBooleanAttribute("nullable", false);
annotations.add(columnBuilder);
fieldBuilders.add(new FieldMetadataBuilder(getId(), Modifier.PRIVATE,
annotations, new JavaSymbolName("id"), LONG_OBJECT));
return fieldBuilders;
}