Examples of AnonymousClassStructureBuilder


Examples of org.jboss.errai.codegen.framework.builder.AnonymousClassStructureBuilder

      @Override
      public String generate(Context context) {
        if (generatedCache != null) return generatedCache;

        final AnonymousClassStructureBuilder builder
                = ObjectBuilder.newInstanceOf(annotationClass, context)
                .extend();

        Class<? extends Annotation> annoClass = annotation.getClass();

        List<Method> sortedMethods = Arrays.asList(annoClass.getDeclaredMethods());
        Collections.sort(sortedMethods, new Comparator<Method>() {
                    @Override
                    public int compare(Method m1, Method m2) {
                        return m1.getName().compareTo(m2.getName());
                    }
           
        });
       
        for (Method method : sortedMethods) {
          if (((method.getModifiers() & (Modifier.PRIVATE | Modifier.PROTECTED)) == 0)
                  && (!"equals".equals(method.getName()) && !"hashCode".equals(method.getName()))) {
            try {
              builder.publicOverridesMethod(method.getName())
                      .append(Stmt.load(method.invoke(annotation)).returnValue()).finish();
            }
            catch (IllegalAccessException e) {
              throw new RuntimeException("error generation annotation wrapper", e);
            }
            catch (InvocationTargetException e) {
              throw new RuntimeException("error generation annotation wrapper", e);
            }
          }
        }

        return generatedCache = prettyPrintJava(builder.finish().toJavaString());
      }

      @Override
      public MetaClass getType() {
        return MetaClassFactory.get(annotationClass);
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.