本文整理汇总了Java中org.springframework.roo.classpath.details.FieldMetadata.getFieldInitializer方法的典型用法代码示例。如果您正苦于以下问题:Java FieldMetadata.getFieldInitializer方法的具体用法?Java FieldMetadata.getFieldInitializer怎么用?Java FieldMetadata.getFieldInitializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.roo.classpath.details.FieldMetadata
的用法示例。
在下文中一共展示了FieldMetadata.getFieldInitializer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendFields
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
private void appendFields() {
final List<? extends FieldMetadata> fields = itdTypeDetails
.getDeclaredFields();
if (fields == null || fields.isEmpty()) {
return;
}
content = true;
for (final FieldMetadata field : fields) {
// Append annotations
for (final AnnotationMetadata annotation : field.getAnnotations()) {
appendIndent();
outputAnnotation(annotation);
this.newLine(false);
}
// Append "<modifier> <fieldType> <fieldName>" portion
appendIndent();
if (field.getModifier() != 0) {
append(Modifier.toString(field.getModifier()));
append(" ");
}
append(field.getFieldType().getNameIncludingTypeParameters(false,
resolver));
append(" ");
append(introductionTo.getSimpleTypeName());
append(".");
append(field.getFieldName().getSymbolName());
// Append initializer, if present
if (field.getFieldInitializer() != null) {
append(" = ");
append(field.getFieldInitializer());
}
// Complete the field declaration
append(";");
this.newLine(false);
this.newLine();
}
}
示例2: getGvNIXXmlElementFieldAnnotation
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
* <p>
* Convert field with @XmlElement annotation to field with @GvNIXXmlElementField
* with its values.
* </p>
* <p>
* Creates {@link FieldMetadata} with @GvNIXXmlElementField annotation even
* if not exists @XmlElement.
* </p>
* TODO to be removed from interface?. This method could be useless outside
* this service.
*
* @param fieldMetadata
* @return {@link FieldMetadata} with @GvNIXXmlElementField annotation.
*/
protected FieldMetadata getGvNIXXmlElementFieldAnnotation(
FieldMetadata field) {
AnnotationMetadata gvNixXmlElementAnnot;
AnnotationMetadata xmlElementAnnot = MemberFindingUtils
.getAnnotationOfType(field.getAnnotations(), new JavaType(
XmlElement.class.getName()));
if (xmlElementAnnot != null) {
// Field has XmlElement annotation: create GvNIXXmlElement from it
gvNixXmlElementAnnot = getXmlElementFieldAnnotation(xmlElementAnnot);
}
else {
AnnotationMetadata xmlElementRefAnnot = MemberFindingUtils
.getAnnotationOfType(field.getAnnotations(), new JavaType(
XmlElementRef.class.getName()));
if (xmlElementRefAnnot != null) {
// Field has XmlElementRef: create GvNIXXmlElement from it
gvNixXmlElementAnnot = getXmlElementRefFieldAnnotation(field);
}
else {
// Field no XmlElement, XmlElementRef: create empty
// GvNIXXmlElement
gvNixXmlElementAnnot = new AnnotationMetadataBuilder(
new JavaType(GvNIXXmlElementField.class.getName()),
new ArrayList<AnnotationAttributeValue<?>>()).build();
}
}
List<AnnotationMetadata> annots = new ArrayList<AnnotationMetadata>();
annots.add(gvNixXmlElementAnnot);
// Create new Field with GvNIXAnnotation.
FieldMetadataBuilder fieldMetadataBuilder = new FieldMetadataBuilder(
field.getDeclaredByMetadataId(), field.getModifier(),
field.getFieldName(), field.getFieldType(),
field.getFieldInitializer());
for (AnnotationMetadata annotationMetadata : annots) {
fieldMetadataBuilder.addAnnotation(annotationMetadata);
}
return fieldMetadataBuilder.build();
}