Package org.springframework.roo.classpath.details

Examples of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails


        // Set up
        final File file = getResource(SIMPLE_CLASS_FILE_PATH);
        final String fileContents = getResourceContents(file);

        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
                .updateAndGetCompilationUnitContents(file.getCanonicalPath(),
                        newSimpleInterfaceDetails);

        saveResult(file, result, "-addedAnnotation");

        checkSimpleClass(result);

        assertTrue(result
                .contains("import org.springframework.roo.addon.tostring.RooToString;"));
        assertTrue(result.contains("@RooToString"));

        // Invoke again
        final ClassOrInterfaceTypeDetails simpleInterfaceDetails2 = typeParsingService
                .getTypeFromString(result, SIMPLE_CLASS_DECLARED_BY_MID,
                        SIMPLE_CLASS_TYPE);

        final String result2 = typeParsingService
                .updateAndGetCompilationUnitContents(file.getCanonicalPath(),
View Full Code Here


            @CliOption(key = "autoUpload", mandatory = false, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false", help = "Whether the file is uploaded automatically when selected") final boolean autoUpload,
            @CliOption(key = "column", mandatory = false, help = "The JPA @Column name") final String column,
            @CliOption(key = "notNull", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Whether this value cannot be null") final boolean notNull,
            @CliOption(key = "permitReservedWords", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates whether reserved words are ignored by Roo") final boolean permitReservedWords) {

        final ClassOrInterfaceTypeDetails cid = typeLocationService
                .getTypeDetails(typeName);
        Validate.notNull(cid, "The type specified, '%s', doesn't exist",
                typeName);

        final String physicalTypeIdentifier = cid.getDeclaredByMetadataId();
        final UploadedFileField fieldDetails = new UploadedFileField(
                physicalTypeIdentifier, fieldName, contentType);
        fieldDetails.setAutoUpload(autoUpload);
        fieldDetails.setNotNull(notNull);
        if (column != null) {
View Full Code Here

            @CliOption(key = "column", mandatory = false, help = "The JPA @Column name") final String column,
            @CliOption(key = "value", mandatory = false, help = "Inserts an optional Spring @Value annotation with the given content") final String value,
            @CliOption(key = "transient", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates to mark the field as transient") final boolean transientModifier,
            @CliOption(key = "permitReservedWords", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates whether reserved words are ignored by Roo") final boolean permitReservedWords) {

        final ClassOrInterfaceTypeDetails cid = typeLocationService
                .getTypeDetails(typeName);
        Validate.notNull(cid, "The type specified, '%s', doesn't exist",
                typeName);

        final String physicalTypeIdentifier = cid.getDeclaredByMetadataId();
        final FieldDetails fieldDetails = new FieldDetails(
                physicalTypeIdentifier, fieldType, fieldName);
        fieldDetails.setNotNull(notNull);
        fieldDetails.setNullRequired(nullRequired);
        if (comment != null) {
View Full Code Here

    public void testSimpleInterfaceNoChanges() throws Exception {
        // Set up
        final File file = getResource(SIMPLE_INTERFACE_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents,
                        SIMPLE_INTERFACE_DECLARED_BY_MID, SIMPLE_INTERFACE_TYPE);

        // Invoke
        final String result = typeParsingService
View Full Code Here

    public void testSimpleClassNoChanges() throws Exception {
        // Set up
        final File file = getResource(SIMPLE_CLASS_FILE_PATH);
        final String fileContents = getResourceContents(file);

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

        // Invoke
        final String result = typeParsingService
View Full Code Here

    public void testSimpleClass2NoChanges() throws Exception {
        // Set up
        final File file = getResource(SIMPLE_CLASS2_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, SIMPLE_CLASS2_DECLARED_BY_MID,
                        SIMPLE_CLASS2_TYPE);

        // Invoke
        final String result = typeParsingService
View Full Code Here

    public void testSimpleClass3NoChanges() throws Exception {
        // Set up
        final File file = getResource(SIMPLE_CLASS3_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, SIMPLE_CLASS3_DECLARED_BY_MID,
                        SIMPLE_CLASS3_TYPE);

        // Invoke
        final String result = typeParsingService
View Full Code Here

    public void testSimpleClass3AddField() throws Exception {
        // Set up
        final File file = getResource(SIMPLE_CLASS3_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, SIMPLE_CLASS3_DECLARED_BY_MID,
                        SIMPLE_CLASS3_TYPE);

        final SetField fieldDetails = new SetField(
                SIMPLE_CLASS3_DECLARED_BY_MID, new JavaType(
                        SET.getFullyQualifiedTypeName(), 0, DataType.TYPE,
                        null, Arrays.asList(SIMPLE_CLASS3_TYPE)),
                new JavaSymbolName("children"), SIMPLE_CLASS3_TYPE,
                Cardinality.ONE_TO_MANY);

        final FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(
                fieldDetails.getPhysicalTypeIdentifier(), Modifier.PRIVATE,
                new ArrayList<AnnotationMetadataBuilder>(),
                fieldDetails.getFieldName(), fieldDetails.getFieldType());
        fieldBuilder.setFieldInitializer("new HashSet<SimpleClass3>()");

        final ClassOrInterfaceTypeDetails newClassDetails = addField(
                simpleInterfaceDetails, fieldBuilder.build());

        // Invoke
        final String result = typeParsingService
                .getCompilationUnitContents(newClassDetails);

        saveResult(file, result, "-addField");

        checkSimple3Class(result);

        assertTrue(result
                .contains("private Set<SimpleClass3> children = new HashSet<SimpleClass3>();"));

        // Add another
        final ClassOrInterfaceTypeDetails simpleInterfaceDetails2 = typeParsingService
                .getTypeFromString(result, SIMPLE_CLASS3_DECLARED_BY_MID,
                        SIMPLE_CLASS3_TYPE);

        final ReferenceField fieldDetails2 = new ReferenceField(
                SIMPLE_CLASS3_DECLARED_BY_MID, SIMPLE_CLASS2_TYPE,
                new JavaSymbolName("referenceField"), Cardinality.MANY_TO_ONE);

        final FieldMetadataBuilder fieldBuilder2 = new FieldMetadataBuilder(
                fieldDetails2.getPhysicalTypeIdentifier(), Modifier.PRIVATE,
                new ArrayList<AnnotationMetadataBuilder>(),
                fieldDetails2.getFieldName(), fieldDetails2.getFieldType());

        final ClassOrInterfaceTypeDetails newClassDetails2 = addField(
                simpleInterfaceDetails2, fieldBuilder2.build());

        // Invoke
        final String result2 = typeParsingService
                .getCompilationUnitContents(newClassDetails2);
View Full Code Here

    public void testRegresion_ROO_1505() throws Exception {
        // Set up
        final File file = getResource(ROO1505_CLASS_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, ROO1505_CLASS_DECLARED_BY_MID,
                        ROO1505_CLASS_TYPE);

        // Invoke
        final String result = typeParsingService
View Full Code Here

        // Set up
        final File file = getResource(SIMPLE_CLASS_FILE_PATH);
        final String fileContents = getResourceContents(file);

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

        final FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(
                SIMPLE_CLASS_DECLARED_BY_MID, Modifier.PRIVATE,
                new JavaSymbolName("newFieldAddedByCode"), new JavaType(
                        String.class), "\"Create by code\"");
        final ClassOrInterfaceTypeDetails newSimpleInterfaceDetails = addField(
                simpleInterfaceDetails, fieldBuilder.build());

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

TOP

Related Classes of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails

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.