Package org.jboss.forge.parser.java

Examples of org.jboss.forge.parser.java.JavaClass.addImport()


      plugin.setName(className);

      plugin.addAnnotation(Alias.class).setStringValue(pluginName.toLowerCase());

      plugin.addField().setPrivate().setName("prompt").setType(ShellPrompt.class).addAnnotation(Inject.class);
      plugin.addImport(PipeOut.class);
      plugin.addImport(Option.class);

      Method<JavaClass> command = plugin
               .addMethod("public void run(PipeOut out, @Option(name=\"value\") final String arg) { System.out.println(\"Executed default command with value: \" + arg); }");
View Full Code Here


      plugin.addAnnotation(Alias.class).setStringValue(pluginName.toLowerCase());

      plugin.addField().setPrivate().setName("prompt").setType(ShellPrompt.class).addAnnotation(Inject.class);
      plugin.addImport(PipeOut.class);
      plugin.addImport(Option.class);

      Method<JavaClass> command = plugin
               .addMethod("public void run(PipeOut out, @Option(name=\"value\") final String arg) { System.out.println(\"Executed default command with value: \" + arg); }");

      if (defaultCommand)
View Full Code Here

      Annotation<JavaClass> manyAnnotation = manyField.addAnnotation(ManyToOne.class);
      Refactory.createGetterAndSetter(many, manyField);

      if (!Strings.isNullOrEmpty(inverseFieldName))
      {
         one.addImport(Set.class);
         one.addImport(HashSet.class);
         if (!one.getCanonicalName().equals(many.getCanonicalName()))
         {
            one.addImport(many.getQualifiedName());
         }
View Full Code Here

      Refactory.createGetterAndSetter(many, manyField);

      if (!Strings.isNullOrEmpty(inverseFieldName))
      {
         one.addImport(Set.class);
         one.addImport(HashSet.class);
         if (!one.getCanonicalName().equals(many.getCanonicalName()))
         {
            one.addImport(many.getQualifiedName());
         }
         Field<JavaClass> oneField = one.addField("private Set<" + many.getName() + "> " + inverseFieldName
View Full Code Here

      {
         one.addImport(Set.class);
         one.addImport(HashSet.class);
         if (!one.getCanonicalName().equals(many.getCanonicalName()))
         {
            one.addImport(many.getQualifiedName());
         }
         Field<JavaClass> oneField = one.addField("private Set<" + many.getName() + "> " + inverseFieldName
                  + "= new HashSet<"
                  + many.getName() + ">();");
         Annotation<JavaClass> oneAnnotation = oneField.addAnnotation(OneToMany.class).setStringValue("mappedBy",
View Full Code Here

         annotation.setLiteralValue("cascade", "CascadeType.ALL");
         annotation.getOrigin().addImport(CascadeType.class);
         annotation.setLiteralValue("orphanRemoval", "true");
         if (!many.getCanonicalName().equals(one.getCanonicalName()))
         {
            many.addImport(one);
         }
         Field<JavaClass> manyField = many.addField("private " + one.getName() + " " + inverseFieldName + ";");
         manyField.addAnnotation(ManyToOne.class);
         Refactory.createGetterAndSetter(many, manyField);
         java.saveJavaSource(many);
View Full Code Here

      if (!Strings.isNullOrEmpty(inverseFieldName))
      {
         annotation.setStringValue("mappedBy", inverseFieldName);

         otherEntity.addImport(Set.class);
         otherEntity.addImport(HashSet.class);
         if (!otherEntity.getCanonicalName().equals(entity.getCanonicalName()))
         {
            otherEntity.addImport(entity.getQualifiedName());
         }
View Full Code Here

      if (!Strings.isNullOrEmpty(inverseFieldName))
      {
         annotation.setStringValue("mappedBy", inverseFieldName);

         otherEntity.addImport(Set.class);
         otherEntity.addImport(HashSet.class);
         if (!otherEntity.getCanonicalName().equals(entity.getCanonicalName()))
         {
            otherEntity.addImport(entity.getQualifiedName());
         }
         Field<JavaClass> otherField = otherEntity.addField("private Set<" + entity.getName() + "> "
View Full Code Here

         otherEntity.addImport(Set.class);
         otherEntity.addImport(HashSet.class);
         if (!otherEntity.getCanonicalName().equals(entity.getCanonicalName()))
         {
            otherEntity.addImport(entity.getQualifiedName());
         }
         Field<JavaClass> otherField = otherEntity.addField("private Set<" + entity.getName() + "> "
                  + inverseFieldName
                  + "= new HashSet<" + entity.getName() + ">();");
         otherField.addAnnotation(ManyToMany.class);
View Full Code Here

   public void testImportWithWildCard() throws ClassNotFoundException
   {
      JavaClass javaClass = JavaParser.create(JavaClass.class);
      javaClass.setPackage("it.coopservice.test");
      javaClass.setName("SimpleClass");
      javaClass.addImport("org.junit.Assert.*");
      assertTrue(javaClass.getImport("org.junit.Assert") != null);
      assertTrue(javaClass.getImport("org.junit.Assert").isWildcard());
   }

   @Test
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.