Examples of AnonymousClassStructureBuilderImpl


Examples of org.jboss.errai.codegen.framework.builder.impl.AnonymousClassStructureBuilderImpl

    }

    return new ObjectMapper() {
      @Override
      public Statement getMarshaller() {
        AnonymousClassStructureBuilderImpl classStructureBuilder
                = Stmt.create(context.getCodegenContext())
                .newObject(parameterizedAs(Marshaller.class, typeParametersOf(JSONObject.class, toMap))).extend();

        classStructureBuilder.publicOverridesMethod("getTypeHandled")
                .append(Stmt.load(toMap).returnValue())
                .finish();

        classStructureBuilder.publicOverridesMethod("getEncodingType")
                .append(Stmt.load("json").returnValue())
                .finish();

        classStructureBuilder.publicOverridesMethod("demarshall",
                Parameter.of(Object.class, "a0"), Parameter.of(MarshallingContext.class, "a1"))
                .append(Stmt.nestedCall(Stmt.newObject(toMap)
                        .withParameters(marshallers.toArray(new Object[marshallers.size()]))).returnValue())
                .finish();

        BlockBuilder<?> marshallMethodBlock = classStructureBuilder.publicOverridesMethod("marshall",
                Parameter.of(Object.class, "a0"), Parameter.of(MarshallingContext.class, "a1"));

        marshallToJSON(marshallMethodBlock, toMap);

        marshallMethodBlock.finish();

        classStructureBuilder.publicOverridesMethod("handles", Parameter.of(Object.class, "a0"))
                .append(Stmt.nestedCall(Bool.and(
                        Bool.notEquals(Stmt.loadVariable("a0").invoke("isObject"), null),
                        Stmt.loadVariable("a0").invoke("isObject").invoke("get", SerializationParts.ENCODED_TYPE)
                                .invoke("equals", Stmt.loadVariable("this").invoke("getTypeHandled").invoke("getName"))
                )).returnValue()).finish();

        return classStructureBuilder.finish();
      }
    };

  }
View Full Code Here

Examples of org.jboss.errai.codegen.framework.builder.impl.AnonymousClassStructureBuilderImpl

    final Class<? extends Annotation> annotationClass = annotation.annotationType();

    return new Statement() {
      @Override
      public String generate(Context context) {
        final AnonymousClassStructureBuilderImpl builder = ObjectBuilder.newInstanceOf(annotationClass, context)
                .extend();

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

        for (Method method : annoClass.getDeclaredMethods()) {
          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 prettyPrintJava(builder.finish().toJavaString());
      }

      @Override
      public MetaClass getType() {
        return MetaClassFactory.get(annotationClass);
View Full Code Here

Examples of org.jboss.errai.ioc.rebind.ioc.codegen.builder.impl.AnonymousClassStructureBuilderImpl

    final String subject = CDI.getSubjectNameByType(parmClassName);
    final Annotation[] qualifiers = InjectUtil.extractQualifiers(instance).toArray(new Annotation[0]);
    final Set<String> qualifierNames = CDI.getQualifiersPart(qualifiers);

    AnonymousClassStructureBuilderImpl callBack = Stmt.newObject(AbstractCDIEventCallback.class).extend();

    BlockBuilder<AnonymousClassStructureBuilderImpl> callBackBlock;
    if (qualifierNames != null) {
      callBackBlock = callBack.initialize();
      for (String qualifierName : qualifierNames) {
        callBackBlock.append(Stmt.loadClassMember("qualifiers").invoke("add", qualifierName));
      }
      callBack = callBackBlock.finish();
    }

    callBackBlock = callBack.publicOverridesMethod("callback", Parameter.of(Message.class, "message"))
        .append(Stmt.declareVariable("msgQualifiers", new TypeLiteral<Set<String>>() {},
            Stmt.loadVariable("message").invoke("get", Set.class, CDIProtocol.QUALIFIERS)))
        .append(Stmt
            .if_(Bool.or(
                Stmt.loadClassMember("qualifiers").invoke("equals", Refs.get("msgQualifiers")),
View Full Code Here

Examples of org.jboss.errai.ioc.rebind.ioc.codegen.builder.impl.AnonymousClassStructureBuilderImpl

    final Class<? extends Annotation> annotationClass = annotation.annotationType();

    return new Statement() {
      @Override
      public String generate(Context context) {
        final AnonymousClassStructureBuilderImpl builder = ObjectBuilder.newInstanceOf(annotationClass, context)
                .extend();

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

        for (Method method : annoClass.getDeclaredMethods()) {
          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 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.