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
                .getCompilationUnitContents(newSimpleInterfaceDetails);

        // save to file for debug
        saveResult(file, result, "-addedAnnotation");

        checkSimpleClass(result);

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

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

        final String result2 = typeParsingService
                .getCompilationUnitContents(simpleInterfaceDetails2);
View Full Code Here


    @Reference private TypeManagementService typeManagementService;

    public void addEqualsAndHashCodeMethods(final JavaType javaType,
            final boolean appendSuper, final Set<String> excludeFields) {
        // Add @RooEquals annotation to class if not yet present
        final ClassOrInterfaceTypeDetails cid = typeLocationService
                .getTypeDetails(javaType);
        if (cid == null || cid.getTypeAnnotation(ROO_EQUALS) != null) {
            return;
        }

        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                ROO_EQUALS);
View Full Code Here

            final JavaType aspectName,
            final PhysicalTypeMetadata governorPhysicalTypeMetadata,
            final String itdFilename) {
        final ServiceAnnotationValues annotationValues = new ServiceAnnotationValues(
                governorPhysicalTypeMetadata);
        final ClassOrInterfaceTypeDetails cid = governorPhysicalTypeMetadata
                .getMemberHoldingTypeDetails();
        if (cid == null) {
            return null;
        }
        final MemberDetails memberDetails = memberDetailsScanner
View Full Code Here

        return fields;
    }

    private ClassOrInterfaceTypeDetails getMostConcreteClassOrInterfaceTypeDetails(
            final List<MemberHoldingTypeDetails> memberHoldingTypeDetailsList) {
        ClassOrInterfaceTypeDetails cid = null;
        // The last ClassOrInterfaceTypeDetails is the most concrete as dictated
        // by the logic in MemberDetailsScannerImpl
        for (final MemberHoldingTypeDetails memberHoldingTypeDetails : memberHoldingTypeDetailsList) {
            if (memberHoldingTypeDetails instanceof ClassOrInterfaceTypeDetails) {
                cid = (ClassOrInterfaceTypeDetails) memberHoldingTypeDetails;
View Full Code Here

    }

    private String getSuffix(
            final List<MemberHoldingTypeDetails> memberHoldingTypeDetailsList,
            final boolean singular, final Map<String, String> pluralMap) {
        final ClassOrInterfaceTypeDetails cid = getMostConcreteClassOrInterfaceTypeDetails(memberHoldingTypeDetailsList);
        if (singular) {
            return cid.getName().getSimpleTypeName();
        }
        String plural = pluralMap.get(cid.getDeclaredByMetadataId());
        for (final AnnotationMetadata annotationMetadata : cid.getAnnotations()) {
            if (annotationMetadata.getAnnotationType()
                    .getFullyQualifiedTypeName()
                    .equals(ROO_PLURAL.getFullyQualifiedTypeName())) {
                final AnnotationAttributeValue<?> annotationAttributeValue = annotationMetadata
                        .getAttribute(new JavaSymbolName("value"));
View Full Code Here

        if (catalystAnnotationType == null || userDefinedNameAttribute == null) {
            return null;
        }
        final String suffix = suffixPlural || suffixSingular ? getSuffix(
                memberHoldingTypeDetailsList, suffixSingular, pluralMap) : "";
        final ClassOrInterfaceTypeDetails cid = getMostConcreteClassOrInterfaceTypeDetails(memberHoldingTypeDetailsList);
        for (final AnnotationMetadata annotationMetadata : cid.getAnnotations()) {
            if (annotationMetadata.getAnnotationType()
                    .getFullyQualifiedTypeName()
                    .equals(catalystAnnotationType.getFullyQualifiedTypeName())) {
                final AnnotationAttributeValue<?> annotationAttributeValue = annotationMetadata
                        .getAttribute(userDefinedNameAttribute);
View Full Code Here

        return memberDetailsScanner.getMemberDetails(getClass().getName(),
                typeDetails);
    }

    private MemberDetails getMemberDetails(final JavaType type) {
        final ClassOrInterfaceTypeDetails typeDetails = typeLocationService
                .getTypeDetails(type);
        if (typeDetails == null) {
            return null;
        }
        return memberDetailsScanner.getMemberDetails(getClass().getName(),
View Full Code Here

    private void updateCache(final JavaType domainType) {
        if (!haveAssociatedTypesChanged(domainType)) {
            return;
        }

        final ClassOrInterfaceTypeDetails domainTypeDetails = typeLocationService
                .getTypeDetails(domainType);
        if (domainTypeDetails == null
                || !domainTypeDetails.getCustomData().keySet()
                        .contains(CustomDataKeys.PERSISTENT_TYPE)) {
            return;
        }

        final MemberDetails memberDetails = getMemberDetails(domainTypeDetails);
View Full Code Here

                    + javaType.getFullyQualifiedTypeName();
        }
        final StringBuilder sb = new StringBuilder();
        sb.append("Java Type  : ").append(javaType.getFullyQualifiedTypeName())
                .append(System.getProperty("line.separator"));
        final ClassOrInterfaceTypeDetails javaTypeDetails = typeLocationService
                .getTypeDetails(javaType);
        if (javaTypeDetails == null) {
            sb.append("Java type details unavailable").append(
                    System.getProperty("line.separator"));
        }
View Full Code Here

     * @return a non-<code>null</code> mock
     */
    private ClassOrInterfaceTypeDetails getMockService(
            final String findAllMethod, final String saveMethod,
            final String updateMethod, final String findEntriesMethod) {
        final ClassOrInterfaceTypeDetails mockServiceInterface = mock(ClassOrInterfaceTypeDetails.class);
        final JavaType mockServiceType = mock(JavaType.class);
        final ServiceAnnotationValues mockServiceAnnotationValues = mock(ServiceAnnotationValues.class);

        when(mockServiceType.getSimpleTypeName()).thenReturn("PersonService");
        when(mockServiceInterface.getName()).thenReturn(mockServiceType);
        when(mockServiceInterface.getDeclaredByMetadataId()).thenReturn(
                SERVICE_MID);
        when(mockServiceAnnotationValues.getFindAllMethod()).thenReturn(
                findAllMethod);
        when(mockServiceAnnotationValues.getFindEntriesMethod()).thenReturn(
                findEntriesMethod);
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.