本文整理汇总了Java中org.springframework.roo.classpath.details.FieldMetadata.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java FieldMetadata.getAnnotations方法的具体用法?Java FieldMetadata.getAnnotations怎么用?Java FieldMetadata.getAnnotations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.roo.classpath.details.FieldMetadata
的用法示例。
在下文中一共展示了FieldMetadata.getAnnotations方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCompositeKeyColumn
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
private boolean isCompositeKeyColumn(final Column column) {
if (!identifierHolder.isEmbeddedIdField()) {
return false;
}
for (final FieldMetadata field : identifierHolder
.getEmbeddedIdentifierFields()) {
for (final AnnotationMetadata annotation : field.getAnnotations()) {
if (!annotation.getAnnotationType().equals(COLUMN)) {
continue;
}
final AnnotationAttributeValue<?> nameAttribute = annotation
.getAttribute(new JavaSymbolName(NAME));
if (nameAttribute != null) {
final String name = (String) nameAttribute.getValue();
if (column.getName().equals(name)) {
return true;
}
}
}
}
return false;
}
示例2: toActionScriptType
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
public static ActionScriptType toActionScriptType(FieldMetadata javaField) {
ActionScriptType asType = toActionScriptType(javaField.getFieldType());
if (asType.isNumeric()) {
boolean isVersion = false;
for (AnnotationMetadata annotation : javaField.getAnnotations()) {
if (annotation.getAnnotationType().getFullyQualifiedTypeName()
.equals("javax.persistence.Version")) {
isVersion = true;
}
}
if (isVersion) {
return ActionScriptType.NUMBER_TYPE;
}
}
return asType;
}
示例3: getEntityToManyFields
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/** {@inheritDoc} */
public List<FieldMetadata> getEntityToManyFields(JavaType entity) {
List<FieldMetadata> toManyFields = new ArrayList<FieldMetadata>();
ClassOrInterfaceTypeDetails entityTypeDetails = getTypeLocationService()
.getTypeDetails(entity);
Validate.notNull(entityTypeDetails, "Cannot locate Metadata for '"
.concat(entity.getFullyQualifiedTypeName()).concat("'."));
MemberDetails entityMemberDetails = getMemberDetailsScanner()
.getMemberDetails(getClass().getName(), entityTypeDetails);
List<FieldMetadata> entityFields = entityMemberDetails.getFields();
for (FieldMetadata entityField : entityFields) {
for (AnnotationMetadata entityFieldAnnotation : entityField
.getAnnotations()) {
if (entityFieldAnnotation.getAnnotationType().equals(
ONETOMANY_ANNOTATION)
|| entityFieldAnnotation.getAnnotationType().equals(
MANYTOMANY_ANNOTATION)) {
toManyFields.add(entityField);
}
}
}
return toManyFields;
}
示例4: isIdFieldAutogenerated
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
* Says if given identifier field is autogenerated or not, that is, if its
* annotated with GeneratedValue
*
* @param identifierField
* @return
*/
private boolean isIdFieldAutogenerated(FieldMetadata identifierField) {
List<AnnotationMetadata> annotations = identifierField.getAnnotations();
for (AnnotationMetadata annotation : annotations) {
if (annotation.getAnnotationType().equals(
new JavaType("javax.persistence.GeneratedValue"))) {
return true;
}
}
return false;
}
示例5: processGaeAnnotations
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
private void processGaeAnnotations(final FieldMetadata field) {
for (final AnnotationMetadata annotation : field.getAnnotations()) {
if (annotation.getAnnotationType().equals(ONE_TO_ONE)
|| annotation.getAnnotationType().equals(MANY_TO_ONE)
|| annotation.getAnnotationType().equals(ONE_TO_MANY)
|| annotation.getAnnotationType().equals(MANY_TO_MANY)) {
builder.addFieldAnnotation(new DeclaredFieldAnnotationDetails(
field, new AnnotationMetadataBuilder(annotation
.getAnnotationType()).build(), true));
builder.addFieldAnnotation(new DeclaredFieldAnnotationDetails(
field, new AnnotationMetadataBuilder(TRANSIENT).build()));
break;
}
}
}
示例6: hasField
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
private boolean hasField(final JavaSymbolName fieldName,
final List<AnnotationMetadata> annotations) {
// Check governor for field
if (governorTypeDetails.getField(fieldName) != null) {
return true;
}
// Check @Column and @JoinColumn annotations on fields in governor with
// the same 'name' as the generated field
final List<FieldMetadata> governorFields = governorTypeDetails
.getFieldsWithAnnotation(COLUMN);
governorFields.addAll(governorTypeDetails
.getFieldsWithAnnotation(JOIN_COLUMN));
for (final FieldMetadata governorField : governorFields) {
governorFieldAnnotations: for (final AnnotationMetadata governorFieldAnnotation : governorField
.getAnnotations()) {
if (governorFieldAnnotation.getAnnotationType().equals(COLUMN)
|| governorFieldAnnotation.getAnnotationType().equals(
JOIN_COLUMN)) {
final AnnotationAttributeValue<?> name = governorFieldAnnotation
.getAttribute(new JavaSymbolName(NAME));
if (name == null) {
continue governorFieldAnnotations;
}
for (final AnnotationMetadata annotationMetadata : annotations) {
final AnnotationAttributeValue<?> columnName = annotationMetadata
.getAttribute(new JavaSymbolName(NAME));
if (columnName != null && columnName.equals(name)) {
return true;
}
}
}
}
}
return false;
}
示例7: addField
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的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());
}
示例8: getMatchingAnnotation
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
* Returns the first annotation of the given field that matches any of this
* matcher's target annotations
*
* @param field the field whose annotations are to be checked (required)
* @return
*/
private AnnotationMetadata getMatchingAnnotation(final FieldMetadata field) {
for (final AnnotationMetadata fieldAnnotation : field.getAnnotations()) {
for (final AnnotationMetadata matchingAnnotation : annotations) {
if (fieldAnnotation
.getAnnotationType()
.getFullyQualifiedTypeName()
.equals(matchingAnnotation.getAnnotationType()
.getFullyQualifiedTypeName())) {
return fieldAnnotation;
}
}
}
return null;
}
示例9: getFieldRelationMasterEntity
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
* Get field from entity related with some master entity defined into the
* fields names list.
*
* @param relationsFields Master fields names
* @param masterEntityDetails Master entity details
* @param entityTypeDetails Entity details
* @return Entity field related with master entity field
*/
protected FieldMetadata getFieldRelationMasterEntity() {
FieldMetadata field = null;
// Get field from master entity with OneToMany or ManyToMany annotation
// and "mappedBy" attribute has some value
String masterField = null;
List<FieldMetadata> masterFields = masterEntityDetails.getFields();
for (FieldMetadata tmpMasterField : masterFields) {
List<AnnotationMetadata> masterFieldAnnotations = tmpMasterField
.getAnnotations();
for (AnnotationMetadata masterFieldAnnotation : masterFieldAnnotations) {
// TODO May be more fields on relationsField var
AnnotationAttributeValue<?> masterFieldMappedBy = masterFieldAnnotation
.getAttribute(new JavaSymbolName("mappedBy"));
JavaType annotationType = masterFieldAnnotation
.getAnnotationType();
boolean isOneToMany = annotationType.equals(new JavaType(
"javax.persistence.OneToMany"));
boolean isManyToMany = annotationType.equals(new JavaType(
"javax.persistence.ManyToMany"));
String fieldName = tmpMasterField.getFieldName()
.getSymbolName();
Iterator<String> fieldRelations = relationsFields.iterator();
boolean isRelation = false;
if (fieldRelations.hasNext()) {
isRelation = fieldName.equals(fieldRelations.next());
}
if ((isOneToMany || isManyToMany) && isRelation) {
masterField = masterFieldMappedBy.getValue().toString();
}
}
}
if (masterField != null) {
// Get field from entity with Column annotation and "name" attribute
// same as previous "mappedBy"
List<FieldMetadata> fields = entityDetails.getFields();
fields.addAll(entityTypeDetails.getPersistenceDetails()
.getRooIdentifierFields());
for (FieldMetadata tmpField : fields) {
if (masterField.equals(tmpField.getFieldName().getSymbolName())) {
field = tmpField;
}
}
}
return field;
}
示例10: getFieldRelationMasterEntity
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
* Get field from entity related with some field.
*/
protected String getFieldRelationMasterEntity(FieldMetadata relationField) {
// TODO Some duplicated code with
// RelatedPatternmetadata.getFieldRelationMasterEntity
// Get field from master entity with OneToMany or ManyToMany annotation
// and "mappedBy" attribute has some value
String masterField = null;
PhysicalTypeMetadata masterEntityDetails = (PhysicalTypeMetadata) getMetadataService()
.get(PhysicalTypeIdentifier.createIdentifier(formbackingType,
LogicalPath.getInstance(Path.SRC_MAIN_JAVA, "")));
List<FieldMetadata> masterFields = masterEntityDetails
.getMemberHoldingTypeDetails().getFieldsWithAnnotation(
new JavaType("javax.persistence.OneToMany"));
masterFields.addAll(masterEntityDetails.getMemberHoldingTypeDetails()
.getFieldsWithAnnotation(
new JavaType("javax.persistence.ManyToMany")));
for (FieldMetadata tmpMasterField : masterFields) {
List<AnnotationMetadata> masterFieldAnnotations = tmpMasterField
.getAnnotations();
for (AnnotationMetadata masterFieldAnnotation : masterFieldAnnotations) {
// TODO May be more fields on relationsField var
AnnotationAttributeValue<?> masterFieldMappedBy = masterFieldAnnotation
.getAttribute(new JavaSymbolName("mappedBy"));
if ((masterFieldAnnotation.getAnnotationType().equals(
new JavaType("javax.persistence.OneToMany")) || masterFieldAnnotation
.getAnnotationType().equals(
new JavaType("javax.persistence.ManyToMany")))
&& tmpMasterField.getFieldName().equals(
relationField.getFieldName())) {
masterField = masterFieldMappedBy.getValue().toString();
}
}
}
return masterField;
}
示例11: getIdentifierAccessorMethodName
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
private JavaSymbolName getIdentifierAccessorMethodName(
final FieldMetadata field, final String metadataIdentificationString) {
if(projectOperations == null){
projectOperations = getProjectOperations();
}
Validate.notNull(projectOperations, "ProjectOperations is required");
final LogicalPath path = PhysicalTypeIdentifier.getPath(field
.getDeclaredByMetadataId());
final String moduleNme = path.getModule();
if (projectOperations.isProjectAvailable(moduleNme)
|| !projectOperations.isFeatureInstalled(FeatureNames.GAE)) {
return null;
}
// We are not interested if the field is annotated with
// @javax.persistence.Transient
for (final AnnotationMetadata annotationMetadata : field
.getAnnotations()) {
if (annotationMetadata.getAnnotationType().equals(TRANSIENT)) {
return null;
}
}
JavaType fieldType = field.getFieldType();
// If the field is a common collection type we need to get the element
// type
if (fieldType.isCommonCollectionType()) {
if (fieldType.getParameters().isEmpty()) {
return null;
}
fieldType = fieldType.getParameters().get(0);
}
final MethodMetadata identifierAccessor = persistenceMemberLocator
.getIdentifierAccessor(fieldType);
if (identifierAccessor != null) {
getMetadataDependencyRegistry().registerDependency(
identifierAccessor.getDeclaredByMetadataId(),
metadataIdentificationString);
return identifierAccessor.getMethodName();
}
return null;
}
示例12: 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();
}
}
示例13: fieldExist
import org.springframework.roo.classpath.details.FieldMetadata; //导入方法依赖的package包/类
/**
* Check if recived field exist
*
* @param mutableTypeDetails
* @param field
* @return
*/
private boolean fieldExist(
ClassOrInterfaceTypeDetailsBuilder mutableTypeDetails,
FieldMetadata field) {
boolean annotationFound;
boolean found = false;
for (FieldMetadataBuilder fieldBuilder : mutableTypeDetails
.getDeclaredFields()) {
if (!fieldBuilder.getFieldType().equals(field.getFieldType())) {
continue;
}
if (!fieldBuilder.getFieldName().equals(field.getFieldName())) {
continue;
}
if (fieldBuilder.getAnnotations() != null
&& field.getAnnotations() == null) {
continue;
}
else if (fieldBuilder.getAnnotations() == null
&& field.getAnnotations() != null) {
continue;
}
else if (fieldBuilder.getAnnotations().size() != field
.getAnnotations().size()) {
continue;
}
found = true;
for (AnnotationMetadataBuilder annotation : fieldBuilder
.getAnnotations()) {
annotationFound = false;
for (AnnotationMetadata fieldAnnotation : field
.getAnnotations()) {
if (annotation.getAnnotationType().equals(
fieldAnnotation.getAnnotationType())) {
annotationFound = true;
break;
}
}
if (!annotationFound) {
found = false;
break;
}
}
if (!found) {
continue;
}
return true;
}
return false;
}