本文整理匯總了Java中org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder.addField方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassOrInterfaceTypeDetailsBuilder.addField方法的具體用法?Java ClassOrInterfaceTypeDetailsBuilder.addField怎麽用?Java ClassOrInterfaceTypeDetailsBuilder.addField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder
的用法示例。
在下文中一共展示了ClassOrInterfaceTypeDetailsBuilder.addField方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMethodAdditions
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* Returns the additions that the caller needs to make in order to invoke
* the given method
*
* @param callerMID the caller's metadata ID (required)
* @param method the method being called (required)
* @param repositoryType the type of repository being called
* @param parameterNames the parameter names used by the caller
* @return a non-<code>null</code> set of additions
*/
private MemberTypeAdditions getMethodAdditions(final String callerMID,
final RepositoryJpaLayerMethod method,
final JavaType repositoryType,
final List<MethodParameter> parameters) {
// Create a builder to hold the repository field to be copied into the
// caller
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
callerMID);
final AnnotationMetadataBuilder autowiredAnnotation = new AnnotationMetadataBuilder(
AUTOWIRED);
final String repositoryFieldName = StringUtils
.uncapitalize(repositoryType.getSimpleTypeName());
cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0, Arrays
.asList(autowiredAnnotation), new JavaSymbolName(
repositoryFieldName), repositoryType));
// Create the additions to invoke the given method on this field
final String methodCall = repositoryFieldName + "."
+ method.getCall(parameters);
return new MemberTypeAdditions(cidBuilder, method.getName(),
methodCall, false, parameters);
}
示例2: getMethodAdditions
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* Returns the additions that the caller needs to make in order to invoke
* the given method
*
* @param callerMID the caller's metadata ID (required)
* @param method the method being called (required)
* @param repositoryType the type of repository being called
* @param parameterNames the parameter names used by the caller
* @return a non-<code>null</code> set of additions
*/
private MemberTypeAdditions getMethodAdditions(final String callerMID,
final RepositoryMongoLayerMethod method,
final JavaType repositoryType,
final List<MethodParameter> parameters) {
// Create a builder to hold the repository field to be copied into the
// caller
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
callerMID);
final AnnotationMetadataBuilder autowiredAnnotation = new AnnotationMetadataBuilder(
AUTOWIRED);
final String repositoryFieldName = StringUtils
.uncapitalize(repositoryType.getSimpleTypeName());
cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0, Arrays
.asList(autowiredAnnotation), new JavaSymbolName(
repositoryFieldName), repositoryType));
// Create the additions to invoke the given method on this field
final String methodCall = repositoryFieldName + "."
+ method.getCall(parameters);
return new MemberTypeAdditions(cidBuilder, method.getName(),
methodCall, false, parameters);
}
示例3: getMethodAdditions
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* Returns the additions that the caller needs to make in order to invoke the given method.
* @param callerMID the caller's metadata ID (required)
* @param method the method being called (required)
* @param repositoryType the type of repository being called
* @param parameterNames the parameter names used by the caller
* @return a non-<code>null</code> set of additions
*/
private MemberTypeAdditions getMethodAdditions(final String callerMID, final RepositoryElasticsearchLayerMethod method,
final JavaType repositoryType, final List<MethodParameter> parameters) {
// Create a builder to hold the repository field to be copied into the caller.
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(callerMID);
final AnnotationMetadataBuilder autowiredAnnotation = new AnnotationMetadataBuilder(AUTOWIRED);
final String repositoryFieldName = StringUtils.uncapitalize(repositoryType.getSimpleTypeName());
cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0, Arrays
.asList(autowiredAnnotation), new JavaSymbolName(
repositoryFieldName), repositoryType));
// Create the additions to invoke the given method on this field
final String methodCall = repositoryFieldName + "." + method.getCall(parameters, repositoryFieldName);
return new MemberTypeAdditions(cidBuilder, method.getName(),
methodCall, false, parameters);
}
開發者ID:lbroudoux,項目名稱:spring-roo-addon-layers-repository-elasticsearch,代碼行數:24,代碼來源:RepositoryElasticsearchLayerProvider.java
示例4: getListInnerClass
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* Gets Inner class to manage elements list for batch operations
*
* @return
*/
public ClassOrInterfaceTypeDetails getListInnerClass() {
// Generate inner class name
JavaType listInnerClassJavaType = new JavaType(destination
.getSimpleTypeName().concat("List"), 0, DataType.TYPE, null,
null);
// Create class builder
ClassOrInterfaceTypeDetailsBuilder classBuilder = new ClassOrInterfaceTypeDetailsBuilder(
getId(), Modifier.STATIC | Modifier.PUBLIC,
listInnerClassJavaType, PhysicalTypeCategory.CLASS);
// Add fields
FieldMetadata listField = getListInner_field("list", destination)
.build();
FieldMetadata selectedField = getListInner_field("selected",
new JavaType("Integer")).build();
classBuilder.addField(listField);
classBuilder.addField(selectedField);
// Adds getter/setter for list field
classBuilder.addMethod(getListInner_getter(listField));
classBuilder.addMethod(getListInner_setter(listField));
// Adds getter/setter for selected field
classBuilder.addMethod(getListInner_getter(selectedField));
classBuilder.addMethod(getListInner_setter(selectedField));
// Return generated class
return classBuilder.build();
}
示例5: addField
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public static ClassOrInterfaceTypeDetails addField(
final ClassOrInterfaceTypeDetails ptd, final FieldMetadata field) {
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
ptd);
cidBuilder.addField(field);
return cidBuilder.build();
}
示例6: injectJmsTemplate
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void injectJmsTemplate(final JavaType targetType,
final JavaSymbolName fieldName, final boolean asynchronous) {
Validate.notNull(targetType, "Java type required");
Validate.notNull(fieldName, "Field name required");
final ClassOrInterfaceTypeDetails targetTypeDetails = typeLocationService
.getTypeDetails(targetType);
Validate.isTrue(targetTypeDetails != null,
"Cannot locate source for '%s'",
targetType.getFullyQualifiedTypeName());
final String declaredByMetadataId = targetTypeDetails
.getDeclaredByMetadataId();
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
targetTypeDetails);
// Create the field
cidBuilder.addField(new FieldMetadataBuilder(declaredByMetadataId,
PRIVATE | TRANSIENT, Arrays
.asList(new AnnotationMetadataBuilder(AUTOWIRED)),
fieldName, JMS_OPERATIONS));
// Create the method
cidBuilder.addMethod(createSendMessageMethod(fieldName,
declaredByMetadataId, asynchronous));
if (asynchronous) {
ensureSpringAsynchronousSupportEnabled();
}
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
示例7: injectEmailTemplate
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void injectEmailTemplate(final JavaType targetType,
final JavaSymbolName fieldName, final boolean async) {
Validate.notNull(targetType, "Java type required");
Validate.notNull(fieldName, "Field name required");
final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
annotations.add(new AnnotationMetadataBuilder(AUTOWIRED));
// Obtain the physical type and its mutable class details
final String declaredByMetadataId = typeLocationService
.getPhysicalTypeIdentifier(targetType);
final ClassOrInterfaceTypeDetails existing = typeLocationService
.getTypeDetails(targetType);
if (existing == null) {
LOGGER.warning("Aborting: Unable to find metadata for target type '"
+ targetType.getFullyQualifiedTypeName() + "'");
return;
}
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
existing);
// Add the MailSender field
final FieldMetadataBuilder mailSenderFieldBuilder = new FieldMetadataBuilder(
declaredByMetadataId, PRIVATE_TRANSIENT, annotations,
fieldName, MAIL_SENDER);
cidBuilder.addField(mailSenderFieldBuilder);
// Add the "sendMessage" method
cidBuilder.addMethod(getSendMethod(fieldName, async,
declaredByMetadataId, cidBuilder));
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}
示例8: addField
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
public void addField(final FieldMetadata field) {
Validate.notNull(field, "Field metadata not provided");
// Obtain the physical type and ITD mutable details
final PhysicalTypeMetadata ptm = (PhysicalTypeMetadata) metadataService
.get(field.getDeclaredByMetadataId());
Validate.notNull(ptm, "Java source code unavailable for type %s",
PhysicalTypeIdentifier.getFriendlyName(field
.getDeclaredByMetadataId()));
final PhysicalTypeDetails ptd = ptm.getMemberHoldingTypeDetails();
Validate.notNull(ptd,
"Java source code details unavailable for type %s",
PhysicalTypeIdentifier.getFriendlyName(field
.getDeclaredByMetadataId()));
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
(ClassOrInterfaceTypeDetails) ptd);
// Automatically add JSR 303 (Bean Validation API) support if there is
// no current JSR 303 support but a JSR 303 annotation is present
boolean jsr303Required = false;
for (final AnnotationMetadata annotation : field.getAnnotations()) {
if (annotation.getAnnotationType().getFullyQualifiedTypeName()
.startsWith("javax.validation")) {
jsr303Required = true;
break;
}
}
final LogicalPath path = PhysicalTypeIdentifier.getPath(cidBuilder
.getDeclaredByMetadataId());
if (jsr303Required) {
// It's more likely the version below represents a later version
// than any specified in the user's own dependency list
projectOperations.addDependency(path.getModule(),
"javax.validation", "validation-api", "1.0.0.GA");
}
cidBuilder.addField(field);
createOrUpdateTypeOnDisk(cidBuilder.build());
}
示例9: addCustomArtifactToRevisionItem
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void addCustomArtifactToRevisionItem(
ClassOrInterfaceTypeDetailsBuilder classBuilder) {
classBuilder.addField(createRevisionItemField());
classBuilder.addField(createRevisionEntityRevisionField());
classBuilder.addField(createRevisionTypeField());
classBuilder.addConstructor(createRevisionItemConstructor());
classBuilder.addMethod(createRevisionItemCreateList());
}
示例10: getMethodAdditions
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* Returns the additions the caller should make in order to invoke the given
* method for the given domain entity.
*
* @param callerMID the caller's metadata ID (required)
* @param methodName the name of the method being invoked (required)
* @param serviceInterface the domain service type (required)
* @param parameterNames the names of the parameters being passed by the
* caller to the method
* @return a non-<code>null</code> set of additions
*/
private MemberTypeAdditions getMethodAdditions(final String callerMID,
final String methodName, final JavaType serviceInterface,
final List<MethodParameter> parameters, boolean autowire) {
// The method is supported by this service interface; make a builder
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
callerMID);
final String fieldName = StringUtils.uncapitalize(serviceInterface
.getSimpleTypeName());
if (autowire) {
// Add an autowired field of the type of this service
cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0, Arrays
.asList(new AnnotationMetadataBuilder(AUTOWIRED)),
new JavaSymbolName(fieldName), serviceInterface));
}
else {
// Add a set method of the type of this service
cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0,
new JavaSymbolName(fieldName), serviceInterface, null));
JavaSymbolName setMethodName = new JavaSymbolName("set"
+ serviceInterface.getSimpleTypeName());
List<JavaType> parameterTypes = new ArrayList<JavaType>();
parameterTypes.add(serviceInterface);
List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();
parameterNames.add(new JavaSymbolName(fieldName));
final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
bodyBuilder.append("\n\tthis." + fieldName + " = " + fieldName
+ ";\n");
MethodMetadataBuilder setSeviceMethod = new MethodMetadataBuilder(
callerMID, PUBLIC, setMethodName, JavaType.VOID_PRIMITIVE,
AnnotatedJavaType.convertFromJavaTypes(parameterTypes),
parameterNames, bodyBuilder);
cidBuilder.addMethod(setSeviceMethod);
}
// Generate an additions object that includes a call to the method
return MemberTypeAdditions.getInstance(cidBuilder, fieldName,
methodName, false, parameters);
}
示例11: addChecksumFieldToEntity
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* Add checksum field (plus getter/setter) to builder
*
* @param field
* @param getter
* @param setter
* @param typeManagementService
*/
private void addChecksumFieldToEntity(FieldMetadata field,
MethodMetadata getter, MethodMetadata setter,
TypeManagementService typeManagementService) {
PhysicalTypeDetails ptd = governorPhysicalTypeMetadata
.getMemberHoldingTypeDetails();
Validate.isInstanceOf(
ClassOrInterfaceTypeDetails.class,
ptd,
"Java source code is immutable for type "
+ PhysicalTypeIdentifier
.getFriendlyName(governorPhysicalTypeMetadata
.getId()));
ClassOrInterfaceTypeDetailsBuilder mutableTypeDetails = new ClassOrInterfaceTypeDetailsBuilder(
(ClassOrInterfaceTypeDetails) ptd);
// Try to locate an existing field with @javax.persistence.Version
try {
if (!fieldExist(mutableTypeDetails, field)) {
mutableTypeDetails.addField(new FieldMetadataBuilder(
governorTypeDetails.getDeclaredByMetadataId(), field));
}
if (!methodExists(mutableTypeDetails, getter)) {
mutableTypeDetails.addMethod(getter);
}
if (!methodExists(mutableTypeDetails, setter)) {
mutableTypeDetails.addMethod(setter);
}
typeManagementService.createOrUpdateTypeOnDisk(mutableTypeDetails
.build());
}
catch (IllegalArgumentException e) {
// TODO In some cases, one element is added more than one time
LOGGER.finest("Problem adding version field: ".concat(e.toString()));
}
}
示例12: createGvNixWebServiceClass
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder; //導入方法依賴的package包/類
/**
* {@inheritDoc}
* <p>
* Only creates the class if not exists in project.
* </p>
*/
public void createGvNixWebServiceClass(JavaType type,
List<AnnotationMetadata> annots, GvNIXAnnotationType gvNixAnnot,
List<FieldMetadata> fields, List<MethodMetadata> methods,
List<ConstructorMetadata> constrs, List<JavaType> exts,
PhysicalTypeCategory physicalType, List<JavaSymbolName> enumConsts) {
// Metadata Id.
String id = PhysicalTypeIdentifier.createIdentifier(type,
LogicalPath.getInstance(Path.SRC_MAIN_JAVA, ""));
// Determine the canonical filename
String physicalPath = typeLocationService
.getPhysicalTypeCanonicalPath(id);
// Check the file doesn't already exist
if (!fileManager.exists(physicalPath)) {
if (!physicalType.equals(PhysicalTypeCategory.ENUMERATION)) {
enumConsts = null;
}
// Create class
ClassOrInterfaceTypeDetailsBuilder typeDetails = new ClassOrInterfaceTypeDetailsBuilder(
id, Modifier.PUBLIC, type, physicalType);
for (AnnotationMetadata annotationMetadata : annots) {
typeDetails.addAnnotation(annotationMetadata);
}
for (FieldMetadata field : fields) {
typeDetails.addField(field);
}
for (ConstructorMetadata constr : constrs) {
typeDetails.addConstructor(constr);
}
for (MethodMetadata method : methods) {
typeDetails.addMethod(method);
}
for (JavaType ext : exts) {
typeDetails.addExtendsTypes(ext);
}
if (enumConsts != null) {
for (JavaSymbolName enumConst : enumConsts) {
typeDetails.addEnumConstant(enumConst);
}
}
typeManagementService.createOrUpdateTypeOnDisk(typeDetails.build());
}
}