Package org.jboss.forge.parser.java

Examples of org.jboss.forge.parser.java.JavaClass


        final Resource<?> currentResource = shell.getCurrentResource();

        try
        {

            final JavaClass javaClass = getJavaClassFromResource(currentResource);
            for (Field<JavaClass> oneField : javaClass.getFields())
            {
                tokens.add(oneField.getName());
            }

        } catch (FileNotFoundException e)
View Full Code Here


                     description = "The qualified Class to be used as this field's type") final String type
            )
   {
      try
      {
         JavaClass entity = getJavaClass();
         String javaType = (type.toLowerCase().endsWith(".java")) ? type.substring(0, type.length() - 5) : type;

         addFieldTo(entity, javaType, fieldName, Column.class);
      }
      catch (FileNotFoundException e)
View Full Code Here

                     description = "Marks this field to be created as a primitive.",
                     type = PromptType.JAVA_VARIABLE_NAME) final boolean primitive)
   {
      try
      {
         JavaClass entity = getJavaClass();
         if (primitive)
         {
            addFieldTo(entity, boolean.class, fieldName, Column.class);
         }
         else
View Full Code Here

                     description = "Marks this field to be created as a primitive.",
                     type = PromptType.JAVA_VARIABLE_NAME) final boolean primitive)
   {
      try
      {
         JavaClass entity = getJavaClass();
         if (primitive)
         {
            addFieldTo(entity, int.class, fieldName, Column.class);
         }
         else
View Full Code Here

                     description = "Marks this field to be created as a primitive.",
                     type = PromptType.JAVA_VARIABLE_NAME) final boolean primitive)
   {
      try
      {
         JavaClass entity = getJavaClass();
         if (primitive)
         {
            addFieldTo(entity, long.class, fieldName, Column.class);
         }
         else
View Full Code Here

                     type = PromptType.JAVA_CLASS,
                     description = "The qualified Class to be used as this field's type") final String type)
   {
      try
      {
         JavaClass entity = getJavaClass();
         addFieldTo(entity, Class.forName(type), fieldName, Column.class);
      }
      catch (FileNotFoundException e)
      {
         shell.println("Could not locate the @Entity requested. No update was made.");
View Full Code Here

                     description = "The field name",
                     type = PromptType.JAVA_VARIABLE_NAME) final String fieldName)
   {
      try
      {
         JavaClass entity = getJavaClass();
         addTemporalFieldTo(entity, Date.class, fieldName, temporalType);
      }
      catch (FileNotFoundException e)
      {
         shell.println("Could not locate the @Entity requested. No update was made.");
View Full Code Here

                     description = "The field name",
                     type = PromptType.JAVA_VARIABLE_NAME) final String fieldName)
   {
      try
      {
         JavaClass entity = getJavaClass();
         addFieldTo(entity, String.class, fieldName, Column.class);
      }
      catch (FileNotFoundException e)
      {
         shell.println("Could not locate the @Entity requested. No update was made.");
View Full Code Here

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

      try
      {
         JavaClass entityClass = getJavaClass();
         JavaClass fieldEntityClass;
         if (areTypesSame(fieldType, entityClass.getCanonicalName()))
         {
            fieldEntityClass = entityClass;
         }
         else
View Full Code Here

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

      try
      {
         JavaClass entity = getJavaClass();
         JavaClass otherEntity;
         if (areTypesSame(fieldType, entity.getCanonicalName()))
         {
            otherEntity = entity;
         }
         else
         {
            otherEntity = findEntity(fieldType);
            entity.addImport(otherEntity.getQualifiedName());
         }

         if (entity.hasField(fieldName))
         {
            throw new IllegalStateException("Entity [" + entity.getCanonicalName() + "] already has a field named ["
                     + fieldName + "]");
         }
         if (!Strings.isNullOrEmpty(inverseFieldName) && otherEntity.hasField(inverseFieldName))
         {
            throw new IllegalStateException("Entity [" + otherEntity.getCanonicalName()
                     + "] already has a field named ["
                     + inverseFieldName + "]");
         }

         entity.addImport(Set.class);
         entity.addImport(HashSet.class);
         Field<JavaClass> field = entity.addField("private Set<" + otherEntity.getName() + "> " + fieldName
                  + "= new HashSet<"
                  + otherEntity.getName() + ">();");
         Annotation<JavaClass> annotation = field.addAnnotation(ManyToMany.class);
         Refactory.createGetterAndSetter(entity, field);

         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() + "> "
                     + inverseFieldName
                     + "= new HashSet<" + entity.getName() + ">();");
            otherField.addAnnotation(ManyToMany.class);
            Refactory.createGetterAndSetter(otherEntity, otherField);
View Full Code Here

TOP

Related Classes of org.jboss.forge.parser.java.JavaClass

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.