builder.addField(getField(CS_FIELD, CONVERSION_SERVICE));
builder.addConstructor(getConstructor());
}
// "create" methods
final MemberTypeAdditions persistMethod = crudAdditions
.get(PERSIST_METHOD);
if (annotationValues.isCreate() && persistMethod != null) {
builder.addMethod(getCreateMethod(persistMethod));
builder.addMethod(getCreateFormMethod(dependentTypes));
persistMethod.copyAdditionsTo(builder, governorTypeDetails);
}
final MemberTypeAdditions countAllMethod = crudAdditions
.get(COUNT_ALL_METHOD);
final MemberTypeAdditions findMethod = crudAdditions.get(FIND_METHOD);
final MemberTypeAdditions findAllMethod = crudAdditions
.get(FIND_ALL_METHOD);
final MemberTypeAdditions findEntriesMethod = crudAdditions
.get(FIND_ENTRIES_METHOD);
final MemberTypeAdditions findAllSortedMethod = crudAdditions
.get(FIND_ALL_SORTED_METHOD);
final MemberTypeAdditions findEntriesSortedMethod = crudAdditions
.get(FIND_ENTRIES_SORTED_METHOD);
// "show" method
if (findMethod != null) {
builder.addMethod(getShowMethod(idField, findMethod));
findMethod.copyAdditionsTo(builder, governorTypeDetails);
}
// sorted "list" method
if (countAllMethod != null && findAllSortedMethod != null
&& findEntriesSortedMethod != null) {
builder.addMethod(getListMethod(findAllSortedMethod,
countAllMethod, findEntriesSortedMethod));
countAllMethod.copyAdditionsTo(builder, governorTypeDetails);
findAllSortedMethod.copyAdditionsTo(builder, governorTypeDetails);
findEntriesSortedMethod.copyAdditionsTo(builder,
governorTypeDetails);
}
// or "list" method
else if (countAllMethod != null && findAllMethod != null
&& findEntriesMethod != null) {
builder.addMethod(getListMethod(findAllMethod, countAllMethod,
findEntriesMethod));
countAllMethod.copyAdditionsTo(builder, governorTypeDetails);
findAllMethod.copyAdditionsTo(builder, governorTypeDetails);
findEntriesMethod.copyAdditionsTo(builder, governorTypeDetails);
}
// "update" methods
final MemberTypeAdditions updateMethod = crudAdditions
.get(MERGE_METHOD);
if (annotationValues.isUpdate() && updateMethod != null
&& findMethod != null) {
builder.addMethod(getUpdateMethod(updateMethod));
builder.addMethod(getUpdateFormMethod(idField, findMethod));
updateMethod.copyAdditionsTo(builder, governorTypeDetails);
}
// "delete" method
final MemberTypeAdditions deleteMethod = crudAdditions
.get(REMOVE_METHOD);
if (annotationValues.isDelete() && deleteMethod != null
&& findMethod != null) {
builder.addMethod(getDeleteMethod(idField, deleteMethod, findMethod));
deleteMethod.copyAdditionsTo(builder, governorTypeDetails);
}
if (!dateTypes.isEmpty()) {
builder.addMethod(getDateTimeFormatHelperMethod());
}