use of org.springframework.roo.classpath.details.annotations.AnnotatedJavaType in project spring-roo by spring-projects.
the class ServiceMetadata method getFindAllGlobalSearchMethod.
/**
* Method that generates method "findAll" method. This method includes
* GlobalSearch parameters to be able to filter results.
*
* @return MethodMetadata
*/
private MethodMetadata getFindAllGlobalSearchMethod() {
// Define method name
JavaSymbolName methodName = this.findAllGlobalSearchMethod.getMethodName();
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = this.findAllGlobalSearchMethod.getParameterTypes();
// Define method parameter names
List<JavaSymbolName> parameterNames = this.findAllGlobalSearchMethod.getParameterNames();
MethodMetadata existingMethod = getGovernorMethod(methodName, AnnotatedJavaType.convertFromAnnotatedJavaTypes(parameterTypes));
if (existingMethod != null) {
return existingMethod;
}
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.ABSTRACT, methodName, this.findAllGlobalSearchMethod.getReturnType(), parameterTypes, parameterNames, null);
// Build and return a MethodMetadata
return methodBuilder.build();
// instance
}
use of org.springframework.roo.classpath.details.annotations.AnnotatedJavaType in project spring-roo by spring-projects.
the class ServiceMetadata method getCountMethod.
/**
* Method that generates method "count".
*
* @return MethodMetadataBuilder with public long count();
* structure
*/
private MethodMetadata getCountMethod() {
// Define method name
JavaSymbolName methodName = new JavaSymbolName("count");
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();
// Define method parameter names
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
MethodMetadata existingMethod = getGovernorMethod(methodName, AnnotatedJavaType.convertFromAnnotatedJavaTypes(parameterTypes));
if (existingMethod != null) {
return existingMethod;
}
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.ABSTRACT, methodName, JavaType.LONG_PRIMITIVE, parameterTypes, parameterNames, null);
// Build and return a MethodMetadata
return methodBuilder.build();
// instance
}
use of org.springframework.roo.classpath.details.annotations.AnnotatedJavaType in project spring-roo by spring-projects.
the class ServiceMetadata method getSaveMethod.
/**
* Method that generates "save" method.
*
* @return MethodMetadataBuilder with public Entity save(Entity entity);
* structure
*/
private MethodMetadata getSaveMethod() {
// Define save method
JavaSymbolName methodName = new JavaSymbolName("save");
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();
parameterTypes.add(AnnotatedJavaType.convertFromJavaType(this.entity));
// Define method parameter names
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
parameterNames.add(new JavaSymbolName("entity"));
MethodMetadata existingMethod = getGovernorMethod(methodName, AnnotatedJavaType.convertFromAnnotatedJavaTypes(parameterTypes));
if (existingMethod != null) {
return existingMethod;
}
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.ABSTRACT, methodName, this.entity, parameterTypes, parameterNames, null);
// Build a MethodMetadata instance
return methodBuilder.build();
}
use of org.springframework.roo.classpath.details.annotations.AnnotatedJavaType in project spring-roo by spring-projects.
the class ServiceMetadata method getDeleteMethod.
/**
* Method that generates "delete" method.
*
* @return MethodMetadataBuilder with public void delete(Entity entity); structure
*/
private MethodMetadata getDeleteMethod() {
// Define method name
JavaSymbolName methodName = new JavaSymbolName("delete");
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();
parameterTypes.add(AnnotatedJavaType.convertFromJavaType(this.entity));
// Define method parameter names
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
parameterNames.add(new JavaSymbolName(StringUtils.uncapitalize(this.entity.getSimpleTypeName())));
MethodMetadata existingMethod = getGovernorMethod(methodName, AnnotatedJavaType.convertFromAnnotatedJavaTypes(parameterTypes));
if (existingMethod != null) {
return existingMethod;
}
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.ABSTRACT, methodName, JavaType.VOID_PRIMITIVE, parameterTypes, parameterNames, null);
// Build a MethodMetadata instance
return methodBuilder.build();
}
use of org.springframework.roo.classpath.details.annotations.AnnotatedJavaType in project spring-roo by spring-projects.
the class ServiceMetadata method getFindOneMethod.
/**
* Method that generates method "findOne".
*
* @return MethodMetadataBuilder with public Entity findOne(Long id);
* structure
*/
private MethodMetadata getFindOneMethod() {
// Define method name
JavaSymbolName methodName = new JavaSymbolName("findOne");
// Define method parameter types
List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();
parameterTypes.add(AnnotatedJavaType.convertFromJavaType(identifierType));
// Define method parameter names
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
parameterNames.add(entityMetadata.getCurrentIndentifierField().getFieldName());
MethodMetadata existingMethod = getGovernorMethod(methodName, AnnotatedJavaType.convertFromAnnotatedJavaTypes(parameterTypes));
if (existingMethod != null) {
return existingMethod;
}
// Use the MethodMetadataBuilder for easy creation of MethodMetadata
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.ABSTRACT, methodName, entity, parameterTypes, parameterNames, null);
// Build and return a MethodMetadata
return methodBuilder.build();
// instance
}
Aggregations