Examples of JavaClassSource


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

   }

   @Test(expected = IllegalArgumentException.class)
   public void testCreateHashCodeAndEqualsForStatics() throws Exception
   {
      JavaClassSource aClass = Roaster
               .parse(JavaClassSource.class,
                        "public class Foo { private static boolean flag;}");
      FieldSource<JavaClassSource> booleanField = aClass.getField("flag");
      Refactory.createHashCodeAndEquals(aClass, booleanField);
   }
View Full Code Here

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

   }
  
   @Test(expected = IllegalArgumentException.class)
   public void testCreateHashCodeForStatics() throws Exception
   {
      JavaClassSource aClass = Roaster
               .parse(JavaClassSource.class,
                        "public class Foo { private static boolean flag;}");
      FieldSource<JavaClassSource> booleanField = aClass.getField("flag");
      Refactory.createHashCode(aClass, booleanField);
   }
View Full Code Here

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

   }
  
   @Test(expected = IllegalArgumentException.class)
   public void testCreateEqualsForStatics() throws Exception
   {
      JavaClassSource aClass = Roaster
               .parse(JavaClassSource.class,
                        "public class Foo { private static boolean flag;}");
      FieldSource<JavaClassSource> booleanField = aClass.getField("flag");
      Refactory.createEquals(aClass, booleanField);
   }
View Full Code Here

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

   }

   @Test
   public void testCreateHashCodeAndEqualsForPrimitives() throws Exception
   {
      JavaClassSource aClass = Roaster
               .parse(JavaClassSource.class,
                        "public class Foo { private boolean aBoolean; private byte aByte; private char aChar; private short aShort; private int anInt; private long aLong; private float aFloat; private double aDouble; }");
      FieldSource<JavaClassSource> booleanField = aClass.getField("aBoolean");
      FieldSource<JavaClassSource> byteField = aClass.getField("aByte");
      FieldSource<JavaClassSource> charField = aClass.getField("aChar");
      FieldSource<JavaClassSource> shortField = aClass.getField("aShort");
      FieldSource<JavaClassSource> intField = aClass.getField("anInt");
      FieldSource<JavaClassSource> longField = aClass.getField("aLong");
      FieldSource<JavaClassSource> floatField = aClass.getField("aFloat");
      FieldSource<JavaClassSource> doubleField = aClass.getField("aDouble");
      Refactory.createHashCodeAndEquals(aClass, booleanField, byteField, charField, shortField, intField, longField,
               floatField, doubleField);
      List<MethodSource<JavaClassSource>> methods = aClass.getMethods();
      assertTrue(aClass.getMethods().size() == 2);
      MethodSource<JavaClassSource> equals = methods.get(0);
      MethodSource<JavaClassSource> hashcode = methods.get(1);
      assertEqualsForPrimitives(equals);
      assertHashCodeForPrimitives(hashcode);
      assertFalse(aClass.hasSyntaxErrors());
      aClass.removeMethod(equals);
      aClass.removeMethod(hashcode);
      assertTrue(aClass.getMethods().size() == 0);

      // equals only
      Refactory.createEquals(aClass, booleanField, byteField, charField, shortField, intField, longField,
               floatField, doubleField);
      methods = aClass.getMethods();
      assertTrue(aClass.getMethods().size() == 1);
      equals = methods.get(0);
      assertEqualsForPrimitives(equals);
      assertFalse(aClass.hasSyntaxErrors());
      aClass.removeMethod(equals);
      assertTrue(aClass.getMethods().size() == 0);
      // hashCode only
      Refactory.createHashCode(aClass, booleanField, byteField, charField, shortField, intField, longField,
               floatField, doubleField);
      assertTrue(aClass.getMethods().size() == 1);
      methods = aClass.getMethods();
      equals = methods.get(0);
      assertHashCodeForPrimitives(equals);
      assertFalse(aClass.hasSyntaxErrors());
      aClass.removeMethod(equals);
      assertTrue(aClass.getMethods().size() == 0);
   }
View Full Code Here

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

   }

   @Test
   public void testCreateHashCodeAndEqualsForArrays() throws Exception
   {
      JavaClassSource aClass = Roaster
               .parse(JavaClassSource.class,
                        "public class Foo { private boolean[] flags; private Object[] objects;}");
      FieldSource<JavaClassSource> primitiveArrayField = aClass.getField("flags");
      FieldSource<JavaClassSource> objectArrayField = aClass.getField("objects");
      Refactory.createHashCodeAndEquals(aClass, primitiveArrayField, objectArrayField);

      List<MethodSource<JavaClassSource>> methods = aClass.getMethods();
      assertTrue(aClass.getMethods().size() == 2);
      MethodSource<JavaClassSource> equals = methods.get(0);
      MethodSource<JavaClassSource> hashcode = methods.get(1);
      assertHashCodeForArrays(hashcode);
      assertEqualsForArrays(equals);
      assertFalse(aClass.hasSyntaxErrors());
      aClass.removeMethod(equals);
      aClass.removeMethod(hashcode);
      assertTrue(aClass.getMethods().size() == 0);

      Refactory.createEquals(aClass, primitiveArrayField, objectArrayField);
      assertTrue(aClass.getMethods().size() == 1);
      methods = aClass.getMethods();
      equals = methods.get(0);
      assertEqualsForArrays(equals);
      assertFalse(aClass.hasSyntaxErrors());
      aClass.removeMethod(equals);
      assertTrue(aClass.getMethods().size() == 0);

      Refactory.createHashCode(aClass, primitiveArrayField, objectArrayField);
      assertTrue(aClass.getMethods().size() == 1);
      methods = aClass.getMethods();
      hashcode = methods.get(0);
      assertHashCodeForArrays(hashcode);
      assertFalse(aClass.hasSyntaxErrors());
      aClass.removeMethod(hashcode);
      assertTrue(aClass.getMethods().size() == 0);

   }
View Full Code Here

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

      targets = new ArrayList<>();
      for (Resource<?> resource : resourceCollection.getResources())
      {
         JavaResource javaResource = (JavaResource) resource;
         JavaClassSource javaClass = javaResource.getJavaType();
         targets.add(javaClass);
      }

      RestGenerationContext generationContext = createContextFor(uiContext);
      Set<JavaClassSource> endpoints = generateEndpoints(generationContext);
View Full Code Here

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

         else
         {
            continue;
         }

         JavaClassSource entity = (JavaClassSource) javaSource;
         String resourceRootPath = getRootResourcePath(project);
         // Fetch the REST resource path from the existing JAX-RS resource if found.
         String entityResourcePath = parseResourcePath(entity);
         // If the path is not available, construct a default one from the JPA entity name
         // We'll let the user resolve the incorrect path later,
         // if needed through regeneration of the JAX-RS resources.
         String entityName = entity.getName();
         if (entityResourcePath == null || entityResourcePath.isEmpty())
         {
            entityResourcePath = inflector.pluralize(entityName.toLowerCase());
         }
         entityResourcePath = trimSlashes(entityResourcePath);
View Full Code Here

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

      boolean isEmbeddable = isEmbeddableAttribute != null
               && isEmbeddableAttribute.equals(InspectionResultConstants.TRUE);
      if (isEmbeddable)
      {
         String embeddedType = propertyAttributes.get(TYPE);
         JavaClassSource javaClass = getJavaClass(embeddedType);
         List<Map<String, String>> embeddedTypeInspectionResults = metawidgetInspectorFacade.inspect(javaClass);
         List<Map<String, String>> expandedInspectionResults = new ArrayList<Map<String, String>>();
         for (Map<String, String> embeddedPropertyAttribute : embeddedTypeInspectionResults)
         {
            embeddedPropertyAttribute.put(LABEL, StringUtils.uncamelCase(embeddedPropertyAttribute.get(NAME)));
View Full Code Here

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

         {
            rightHandSideType = propertyAttributes.get("parameterized-type");
         }
         String rightHandSideSimpleName = getSimpleName(rightHandSideType);
         propertyAttributes.put("simpleType", rightHandSideSimpleName);
         JavaClassSource javaClass = getJavaClass(rightHandSideType);
         List<Map<String, String>> rhsInspectionResults = metawidgetInspectorFacade.inspect(javaClass);
         List<InspectedProperty> fieldsToDisplay = getPropertiesToDisplay(getDisplayableProperties(rhsInspectionResults));
         InspectedProperty defaultField = fieldsToDisplay.size() > 0 ? fieldsToDisplay.get(0) : null;
         InspectedProperty fieldToDisplay = defaultField;
         /*
 
View Full Code Here

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

         }
         else
         {
            rightHandSideType = propertyAttributes.get("parameterized-type");
         }
         JavaClassSource javaClass = getJavaClass(rightHandSideType);
         for (Member<?> member : javaClass.getMembers())
         {
            // FORGEPLUGINS-120 Ensure that properties with composite keys are detected and omitted from generation
            if (member.hasAnnotation(Id.class) && !javaClass.hasAnnotation(IdClass.class))
            {
               return false;
            }
            if (member.hasAnnotation(EmbeddedId.class))
            {
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.