public void decorateAnnotationsList(
final List<AnnotationMetadataBuilder> annotations) {
Validate.notNull(annotations);
if (notNull) {
annotations.add(new AnnotationMetadataBuilder(NOT_NULL));
}
if (nullRequired) {
annotations.add(new AnnotationMetadataBuilder(NULL));
}
AnnotationMetadataBuilder columnBuilder = null;
if (column != null) {
final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>();
attrs.add(new StringAttributeValue(new JavaSymbolName("name"),
column));
columnBuilder = new AnnotationMetadataBuilder(COLUMN, attrs);
}
if (unique) {
if (columnBuilder != null) {
columnBuilder.addBooleanAttribute("unique", true);
}
else {
final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>();
attrs.add(new BooleanAttributeValue(
new JavaSymbolName("unique"), true));
columnBuilder = new AnnotationMetadataBuilder(COLUMN, attrs);
}
}
if (value != null) {
final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>();
attrs.add(new StringAttributeValue(new JavaSymbolName("value"),
value));
annotations.add(new AnnotationMetadataBuilder(VALUE, attrs));
}
if (fieldName.getSymbolName().equals("created")) {
if (columnBuilder == null) {
columnBuilder = new AnnotationMetadataBuilder(COLUMN);
}
columnBuilder.addBooleanAttribute("updatable", false);
}
if (columnBuilder != null) {
annotations.add(columnBuilder);
}