Package org.jboss.forge.project.facets

Examples of org.jboss.forge.project.facets.JavaSourceFacet


      {
         throw new IllegalStateException("Entity [" + targetEntity.getCanonicalName() + "] already has a field named ["
                  + fieldName + "]");
      }

      JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);

      Field<JavaClass> field = targetEntity.addField();
      field.setName(fieldName).setPrivate().setType(fieldEntity.getName()).addAnnotation(annotation);
      if (!targetEntity.getCanonicalName().equals(fieldEntity.getCanonicalName()))
      {
         targetEntity.addImport(fieldEntity.getQualifiedName());
      }
      Refactory.createGetterAndSetter(targetEntity, field);
      updateToString(targetEntity);

      java.saveJavaSource(targetEntity);
      shell.println("Added field to " + targetEntity.getQualifiedName() + ": " + field);

      return field;
   }
View Full Code Here


      if (targetEntity.hasField(fieldName))
      {
         throw new IllegalStateException("Entity already has a field named [" + fieldName + "]");
      }

      JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);

      Field<JavaClass> field = targetEntity.addField();
      field.setName(fieldName).setPrivate().setType(Types.toSimpleName(fieldType)).addAnnotation(annotation);
      if (!targetEntity.getCanonicalName().equals(fieldType))
      {
         targetEntity.addImport(fieldType);
      }
      Refactory.createGetterAndSetter(targetEntity, field);

      updateToString(targetEntity);
      java.saveJavaSource(targetEntity);
      shell.println("Added field to " + targetEntity.getQualifiedName() + ": " + field);

      return field;
   }
View Full Code Here

   {
      if (targetEntity.hasField(fieldName))
      {
         throw new IllegalStateException("Entity already has a field named [" + fieldName + "]");
      }
      JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);

      Field<JavaClass> field = targetEntity.addField();
      field.setName(fieldName).setPrivate().setType(fieldType).addAnnotation(Temporal.class).setEnumValue(temporalType);
      if (!fieldType.getName().startsWith("java.lang.") && !fieldType.isPrimitive()
               && !fieldType.getCanonicalName().equals(targetEntity.getCanonicalName()))
      {
         targetEntity.addImport(fieldType);
      }
      Refactory.createGetterAndSetter(targetEntity, field);
      updateToString(targetEntity);
      java.saveJavaSource(targetEntity);
      shell.println("Added field to " + targetEntity.getQualifiedName() + ": " + field);

      return field;
   }
View Full Code Here

   {
      if (targetEntity.hasField(fieldName))
      {
         throw new IllegalStateException("Entity already has a field named [" + fieldName + "]");
      }
      JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);

      Field<JavaClass> field = targetEntity.addField();
      field.setName(fieldName).setPrivate().setType(fieldType).addAnnotation(annotation);
     
      Class<?> fieldTypeForImport = fieldType;
      if (fieldType.getComponentType() != null)
      {
          fieldTypeForImport = fieldType.getComponentType();
      }
     
      if (!fieldTypeForImport.getCanonicalName().startsWith("java.lang.") && !fieldTypeForImport.isPrimitive()
               && !fieldTypeForImport.getCanonicalName().equals(targetEntity.getCanonicalName()))
      {
         targetEntity.addImport(fieldTypeForImport);
      }
      Refactory.createGetterAndSetter(targetEntity, field);
      updateToString(targetEntity);
      java.saveJavaSource(targetEntity);
      shell.println("Added field to " + targetEntity.getQualifiedName() + ": " + field);

      return field;
   }
View Full Code Here

   private JavaClass findEntity(final String entity) throws FileNotFoundException
   {
      JavaClass result = null;

      PersistenceFacet scaffold = project.getFacet(PersistenceFacet.class);
      JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);

      if (entity != null)
      {
         result = getJavaClassFrom(java.getJavaResource(entity));
         if (result == null)
         {
            result = getJavaClassFrom(java.getJavaResource(scaffold.getEntityPackage() + "." + entity));
         }
      }

      if (result == null)
      {
View Full Code Here

            }
            else if (res.length == 0)
            {
               if (getCurrentProject().hasFacet(JavaSourceFacet.class))
               {
                  JavaSourceFacet java = getCurrentProject().getFacet(JavaSourceFacet.class);
                  try
                  {
                     JavaResource resource = java.getJavaResource(obj.toString());
                     return resource;
                  }
                  catch (FileNotFoundException e)
                  {
                     throw new RuntimeException(e);
View Full Code Here

            }
            else if (res.length == 0)
            {
               if (getCurrentProject().hasFacet(JavaSourceFacet.class))
               {
                  JavaSourceFacet java = getCurrentProject().getFacet(JavaSourceFacet.class);
                  try
                  {
                     JavaResource resource = java.getJavaResource(obj.toString());
                     return resource;
                  }
                  catch (FileNotFoundException e)
                  {
                     throw new RuntimeException(e);
View Full Code Here

            }
            else if (res.length == 0)
            {
               if (getCurrentProject().hasFacet(JavaSourceFacet.class))
               {
                  JavaSourceFacet java = getCurrentProject().getFacet(JavaSourceFacet.class);
                  try
                  {
                     JavaResource resource = java.getJavaResource(obj.toString());
                     return resource;
                  }
                  catch (FileNotFoundException e)
                  {
                     throw new RuntimeException(e);
View Full Code Here

   @Override
   public void addAsTestClass(final Project project, final JavaClass clazz)
   {
      try {
         JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
         clazz.setName(clazz.getName() + "Test").setPackage(java.getBasePackage());

         if (!clazz.hasAnnotation(RunWith.class))
         {
            Annotation<JavaClass> runWith = clazz.addAnnotation(RunWith.class);
            runWith.setLiteralValue("Arquillian.class");
         }

         if (clazz.hasAnnotation(Ignore.class))
         {
            clazz.removeAnnotation(clazz.getAnnotation(Ignore.class));
         }

         clazz.addImport(Arquillian.class);
         java.saveTestJavaSource(clazz);
      }
      catch (FileNotFoundException e) {
         throw new RuntimeException(e);
      }
   }
View Full Code Here

   @Override
   public Method<JavaClass> buildDefaultDeploymentMethod(final Project project, final JavaClass clazz,
            final Collection<String> deploymentItems)
   {
      try {
         JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);

         JavaResource root = java.getTestJavaResource(java.getBasePackage() + ".Root");
         if (!root.exists())
         {
            java.saveTestJavaSource(JavaParser.create(JavaInterface.class).setName("Root")
                     .setPackage(java.getBasePackage()));
         }
         clazz.addImport(root.getJavaSource());

         clazz.addImport(WebArchive.class);
         clazz.addImport(Deployment.class);
View Full Code Here

TOP

Related Classes of org.jboss.forge.project.facets.JavaSourceFacet

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.