Package org.modeshape.sequencer.javafile.metadata

Examples of org.modeshape.sequencer.javafile.metadata.PackageMetadata


        assertTrue("Not a compilation unit", rootNode.getNodeType() == ASTNode.COMPILATION_UNIT);
    }

    @Test
    public void shouldCreatePackageMetadata() throws Exception {
        PackageMetadata packageMetadata = javaMetadata.createPackageMetadata((CompilationUnit)rootNode);
        assertThat(packageMetadata, is(notNullValue()));
        assertThat(packageMetadata.getName(), is("org.acme"));
        List<AnnotationMetadata> annotations = packageMetadata.getAnnotations();
        for (AnnotationMetadata annotationMetadata : annotations) {
            assertEquals(AnnotationMetadata.Type.MARKER, annotationMetadata.getType());
            assertThat(annotationMetadata.getName(), is("org.acme.annotation.MyPackageAnnotation"));
        }
    }
View Full Code Here


     * @param unit - the compilation unit.
     * @return the package meta data of a compilation unit.
     */
    @SuppressWarnings( "unchecked" )
    protected PackageMetadata createPackageMetadata( CompilationUnit unit ) {
        PackageMetadata packageMetadata = null;
        List<Annotation> annotations = null;
        PackageDeclaration packageDeclaration = unit.getPackage();
        if (packageDeclaration != null) {
            annotations = packageDeclaration.annotations();
            packageMetadata = new PackageMetadata(JavaMetadataUtil.getName(unit.getPackage().getName()));
            if (!annotations.isEmpty()) {
                for (Object object : annotations) {
                    packageMetadata.getAnnotations().add(createAnnotationMetadataFor((Annotation)object));
                }
            }
        }
        return packageMetadata;
    }
View Full Code Here

TOP

Related Classes of org.modeshape.sequencer.javafile.metadata.PackageMetadata

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.