Package org.jboss.forge.roaster.model.source

Examples of org.jboss.forge.roaster.model.source.JavaEnumSource


   }

   public JavaResource createEmptyEnum(Project project, String enumName) throws IOException
   {
      JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class);
      JavaEnumSource enumSource = Roaster.create(JavaEnumSource.class).setName(enumName);
      String packageName = project.getFacet(MetadataFacet.class).getTopLevelPackage() + ".model";
      enumSource.setPackage(packageName);
      return javaSourceFacet.saveJavaSource(enumSource);
   }
View Full Code Here


   }

   @Test
   public void testEnumWithNestedClass()
   {
      JavaEnumSource javaEnum = Roaster
               .parse(JavaEnumSource.class, "package org.example; public enum OuterEnum { " +
                        "  FOO, BAR, BAZ; " +
                        "  public class InnerClass1{ " +
                        "    public class InnerClass3{}" +
                        "  } " +
                        "  public class InnerClass2{} " +
                        "}");

      Assert.assertEquals("org.example.OuterEnum", javaEnum.getCanonicalName());
      List<JavaSource<?>> nestedClasses = javaEnum.getNestedTypes();
      JavaClassSource inner1 = (JavaClassSource) nestedClasses.get(0);
      JavaClassSource inner2 = (JavaClassSource) nestedClasses.get(1);
      Assert.assertEquals(javaEnum, inner1.getEnclosingType());
      Assert.assertEquals("org.example.OuterEnum.InnerClass1", inner1.getCanonicalName());
      Assert.assertEquals("org.example.OuterEnum$InnerClass1", inner1.getQualifiedName());
View Full Code Here

                        "  public enum InnerEnum{A,B,C;} " +
                        "}");

      Assert.assertEquals("org.example.OuterClass", javaClass.getCanonicalName());
      List<JavaSource<?>> nestedClasses = javaClass.getNestedTypes();
      JavaEnumSource inner1 = (JavaEnumSource) nestedClasses.get(0);
      Assert.assertEquals(javaClass, inner1.getEnclosingType());
      Assert.assertEquals("org.example.OuterClass.InnerEnum", inner1.getCanonicalName());
      Assert.assertEquals("org.example.OuterClass$InnerEnum", inner1.getQualifiedName());
      Assert.assertEquals("InnerEnum", inner1.getName());
      Assert.assertEquals(1, nestedClasses.size());
   }
View Full Code Here

   }

   public JavaResource createEmptyEnum(Project project, String enumName) throws IOException
   {
      JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class);
      JavaEnumSource enumSource = Roaster.create(JavaEnumSource.class).setName(enumName);
      String packageName = project.getFacet(JavaSourceFacet.class).getBasePackage() + ".model";
      enumSource.setPackage(packageName);
      return javaSourceFacet.saveJavaSource(enumSource);
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.roaster.model.source.JavaEnumSource

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.