use of org.springframework.roo.shell.CliOptionMandatoryIndicator in project spring-roo by spring-projects.
the class FinderCommands method isFormBeanMandatory.
@CliOptionMandatoryIndicator(command = "finder add", params = { "formBean" })
public boolean isFormBeanMandatory(ShellContext shellContext) {
// Get current value of 'entity'
JavaType entity = getTypeFromEntityParam(shellContext);
if (entity == null) {
return false;
}
// Get current value of returnType
String returnType = shellContext.getParameters().get("returnType");
// This parameter is not mandatory if returnType has not been specified
if (StringUtils.isBlank(returnType)) {
return false;
}
// If returnType has been specified, but it's an entity, this parameter is not
// mandatory
JavaTypeConverter converter = (JavaTypeConverter) getJavaTypeConverter().get(0);
JavaType type = converter.convertFromText(returnType, JavaType.class, PROJECT);
if (type == null) {
return false;
}
ClassOrInterfaceTypeDetails details = getTypeLocationService().getTypeDetails(type);
if (details == null) {
return false;
}
AnnotationMetadata entityAnnotation = details.getAnnotation(RooJavaType.ROO_JPA_ENTITY);
if (entityAnnotation != null) {
return false;
}
return true;
}
Aggregations