public List<FieldMetadata> getFieldsWithAnnotation(final JavaType annotation) { Validate.notNull(annotation, "Annotation required"); final List<FieldMetadata> result = new ArrayList<FieldMetadata>(); MemberHoldingTypeDetails current = this; while (current != null) { for (final FieldMetadata field : current.getDeclaredFields()) { if (MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), annotation) != null) { // Found the annotation on this field result.add(field); } } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return result; }
MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), ROO_PLURAL); if (annotation != null) {
/** * 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; }
destination.getFullyQualifiedTypeName()); Validate.notNull( MemberFindingUtils.getAnnotationOfType(candidate.getAnnotations(), AUTOWIRED), "Field '%s' on '%s' must be @Autowired", collaboratingFieldName, destination.getFullyQualifiedTypeName());
/** * This method generates new field instance using an existing FieldMetadata * * @param declaredByMetadataId * @param field * * @return */ private FieldMetadata getNewField(String declaredByMetadataId, FieldMetadata field) { // Use the FieldMetadataBuilder for easy creation of FieldMetadata // based on existing field FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(declaredByMetadataId, field.getModifier(), field.getFieldName(), field.getFieldType(), field.getFieldInitializer()); fieldBuilder.setAnnotations(field.getAnnotations()); return fieldBuilder.build(); }
for (final AnnotationMetadata annotation : field.getAnnotations()) { JavaParserAnnotationMetadataBuilder.addAnnotationToList(compilationUnitServices, annotations, annotation);
for (final AnnotationMetadata annotation : field.getAnnotations()) { if (annotation.getAnnotationType().getFullyQualifiedTypeName().startsWith("javax.validation")) { jsr303Required = true;
for (final AnnotationMetadata annotationMetadata : field.getAnnotations()) { if (annotationMetadata.getAnnotationType().equals(TRANSIENT)) { return null;
fieldBuilder = new FieldMetadataBuilder(fieldDetails); fieldBuilder.setModifier(field.getModifier()); fieldBuilder.setAnnotations(field.getAnnotations()); } else if (field.getFieldType().getFullyQualifiedTypeName().equals("java.util.List")) { JavaType fieldType = field.getFieldType().getParameters().get(0); fieldBuilder = new FieldMetadataBuilder(fieldDetails); fieldBuilder.setModifier(field.getModifier()); fieldBuilder.setAnnotations(field.getAnnotations()); } else { List<AnnotationMetadata> annotations = field.getAnnotations(); for (AnnotationMetadata annotation : annotations) { if (annotation.getAnnotationType().getFullyQualifiedTypeName()
final boolean hasAnnotation = MemberFindingUtils.getAnnotationOfType(declaredFieldAnnotationDetails.getField() .getAnnotations(), declaredFieldAnnotationDetails.getFieldAnnotation() .getAnnotationType()) != null; if (!declaredFieldAnnotationDetails.isRemoveAnnotation()) {
MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), SIZE); if (sizeAnnotation != null && sizeAnnotation.getAttribute(MAX_SYMBOL) != null) { final Integer maxValue = (Integer) sizeAnnotation.getAttribute(MAX_SYMBOL).getValue(); MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), DIGITS); final AnnotationMetadata decimalMinAnnotation = MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), DECIMAL_MIN); final AnnotationMetadata decimalMaxAnnotation = MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), DECIMAL_MAX);
if (MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), PAST) != null) { builder.getImportRegistrationResolver().addImport(DATE); initializer = "new Date(new Date().getTime() - 10000000L)"; } else if (MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), FUTURE) != null) { builder.getImportRegistrationResolver().addImport(DATE); initializer = "new Date(new Date().getTime() + 10000000L)"; if (MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), PAST) != null) { initializer = calendarString + " - 1)"; } else if (MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), FUTURE) != null) { initializer = calendarString + " + 1)"; } else { if (MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), VALIDATOR_CONSTRAINTS_EMAIL) != null || fieldName.toLowerCase().contains("email")) { initializer = "\"foo\" + " + INDEX_VAR + " + \"@bar.com\""; MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), SIZE); if (sizeAnnotation != null) { final AnnotationAttributeValue<?> maxValue = sizeAnnotation.getAttribute(MAX_SYMBOL);
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; } } }
for (final AnnotationMetadata annotation : field.getAnnotations()) { appendIndent(); outputAnnotation(annotation);
private void writeInnerTypeFields(final ClassOrInterfaceTypeDetails innerType) { for (final FieldMetadata field : innerType.getDeclaredFields()) { indent(); this.newLine(false); // Append annotations for (final AnnotationMetadata annotation : field.getAnnotations()) { appendIndent(); outputAnnotation(annotation); this.newLine(false); } appendIndent(); if (field.getModifier() != 0) { append(Modifier.toString(field.getModifier())); append(" "); } append(field.getFieldType().getNameIncludingTypeParameters(false, resolver)); 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); indentRemove(); } }
MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), MIN); final AnnotationMetadata maxAnnotation = MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), MAX); if (minAnnotation != null && maxAnnotation == null) { final Number minValue = (Number) minAnnotation.getAttribute(VALUE).getValue();
public List<FieldMetadata> getFieldsWithAnnotation(final JavaType annotation) { Validate.notNull(annotation, "Annotation required"); final List<FieldMetadata> result = new ArrayList<FieldMetadata>(); MemberHoldingTypeDetails current = this; while (current != null) { for (final FieldMetadata field : current.getDeclaredFields()) { if (MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), annotation) != null) { // Found the annotation on this field result.add(field); } } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return result; }
/** * Indicates whether the annotation introduced via this field. * * @para field to be check annotations * @param annotation to be check if exists * @return true if annotation exists into field, false otherwise */ public boolean hasAnnotation(FieldMetadata field, String annotation) { // Get field annotation of GvNIXXmlElementField type AnnotationMetadata annot = MemberFindingUtils.getAnnotationOfType( field.getAnnotations(), new JavaType(annotation)); if (annot == null) { return false; } return true; }
/** * 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; }
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; } } }