Package org.springframework.roo.classpath.details.annotations

Examples of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder


        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, SIMPLE_CLASS_DECLARED_BY_MID,
                        SIMPLE_CLASS_TYPE);

        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                new JavaType(
                        "org.springframework.roo.addon.tostring.RooToString"));
        final ClassOrInterfaceTypeDetails newSimpleInterfaceDetails = addAnnotation(
                simpleInterfaceDetails, annotationBuilder.build());

        // Invoke
        final String result = typeParsingService
                .getCompilationUnitContents(newSimpleInterfaceDetails);
View Full Code Here


    public final boolean addAnnotation(
            final AnnotationMetadata annotationMetadata) {
        if (annotationMetadata == null) {
            return false;
        }
        return addAnnotation(new AnnotationMetadataBuilder(annotationMetadata));
    }
View Full Code Here

        return null;
    }

    private void init(final IdentifiableAnnotatedJavaStructure existing) {
        for (final AnnotationMetadata element : existing.getAnnotations()) {
            this.annotations.add(new AnnotationMetadataBuilder(element));
        }
    }
View Full Code Here

    public final void setAnnotations(
            final Collection<AnnotationMetadata> annotations) {
        final List<AnnotationMetadataBuilder> annotationBuilders = new ArrayList<AnnotationMetadataBuilder>();
        for (final AnnotationMetadata annotationMetadata : annotations) {
            annotationBuilders.add(new AnnotationMetadataBuilder(
                    annotationMetadata));
        }
        setAnnotations(annotationBuilders);
    }
View Full Code Here

        }
        this.attributeValues = attributeValues;
    }

    public AnnotationMetadata build() {
        final AnnotationMetadataBuilder annotationMetadataBuilder = new AnnotationMetadataBuilder(
                annotationType, attributeValues);
        return annotationMetadataBuilder.build();
    }
View Full Code Here

        final MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
                getId(), PUBLIC, methodName, JavaType.VOID_PRIMITIVE,
                new ArrayList<AnnotatedJavaType>(),
                new ArrayList<JavaSymbolName>(), bodyBuilder);
        methodBuilder.addAnnotation(new AnnotationMetadataBuilder(
                POST_CONSTRUCT));
        return methodBuilder;
    }
View Full Code Here

    private AnnotationMetadata getManagedBeanAnnotation(final String beanName) {
        final AnnotationMetadata annotation = getTypeAnnotation(MANAGED_BEAN);
        if (annotation == null) {
            return null;
        }
        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                annotation);
        annotationBuilder.addStringAttribute("name", beanName);
        return annotationBuilder.build();
    }
View Full Code Here

    private AnnotationMetadata getScopeAnnotation() {
        if (hasScopeAnnotation()) {
            return null;
        }
        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                SESSION_SCOPED);
        return annotationBuilder.build();
    }
View Full Code Here

    @Override
    public void decorateAnnotationsList(
            final List<AnnotationMetadataBuilder> annotations) {
        super.decorateAnnotationsList(annotations);
        if (past) {
            annotations.add(new AnnotationMetadataBuilder(PAST));
        }
        if (future) {
            annotations.add(new AnnotationMetadataBuilder(FUTURE));
        }
        if (persistenceType != null) {
            // Add JSR 220 @Temporal annotation
            String value = null;
            if (persistenceType == DateFieldPersistenceType.JPA_DATE) {
                value = "DATE";
            }
            else if (persistenceType == DateFieldPersistenceType.JPA_TIME) {
                value = "TIME";
            }
            else if (persistenceType == DateFieldPersistenceType.JPA_TIMESTAMP) {
                value = "TIMESTAMP";
            }
            final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>();
            attrs.add(new EnumAttributeValue(new JavaSymbolName("value"),
                    new EnumDetails(TEMPORAL_TYPE, new JavaSymbolName(value))));
            annotations.add(new AnnotationMetadataBuilder(TEMPORAL, attrs));
        }
        // Always add a DateTimeFormat annotation
        final List<AnnotationAttributeValue<?>> attributes = new ArrayList<AnnotationAttributeValue<?>>();
        if (pattern != null) {
            attributes.add(new StringAttributeValue(new JavaSymbolName(
                    "pattern"), pattern));
        }
        else {
            final String dateStyle = null != dateFormat ? String
                    .valueOf(dateFormat.getShortKey()) : "M";
            final String timeStyle = null != timeFormat ? String
                    .valueOf(timeFormat.getShortKey()) : "-";
            attributes.add(new StringAttributeValue(
                    new JavaSymbolName("style"), dateStyle + timeStyle));
        }
        annotations.add(new AnnotationMetadataBuilder(DATE_TIME_FORMAT,
                attributes));
    }
View Full Code Here

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, SIMPLE_CLASS_DECLARED_BY_MID,
                        SIMPLE_CLASS_TYPE);

        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                new JavaType(
                        "org.springframework.roo.addon.tostring.RooToString"));
        final ClassOrInterfaceTypeDetails newSimpleInterfaceDetails = addAnnotation(
                simpleInterfaceDetails, annotationBuilder.build());

        // Invoke
        final String result = typeParsingService
                .getCompilationUnitContents(newSimpleInterfaceDetails);
View Full Code Here

TOP

Related Classes of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.