Package org.jboss.errai.codegen.framework

Examples of org.jboss.errai.codegen.framework.Statement


  public static Statement demarshal(Parameter param) {
    return demarshal(param.getType(), Variable.get(param.getName()));
  }
 
  public static Statement demarshal(MetaClass type, Statement statement) {
    Statement demarshallingStatement;
    if (type.asUnboxed().isPrimitive() || type.equals(MetaClassFactory.get(String.class))) {
      demarshallingStatement =  PrimitiveTypeMarshaller.demarshal(type, statement);
    }
    else {
      demarshallingStatement = Stmt.invokeStatic(JSONDecoderCli.class, "decode", statement);
View Full Code Here


   *
   * @param method
   * @return statement representing the GWT RequestBuilder method
   */
  public static Statement fromMethod(MetaMethod method) {
    Statement gwtRequestMethod = null;
    for (Class<? extends Annotation> jaxrsMethod : map.keySet()) {
      if (method.isAnnotationPresent(jaxrsMethod)) {
        gwtRequestMethod = map.get(jaxrsMethod);
        break;
      }
View Full Code Here

      generateRequestBuilder(methodBlock);
      generateHeaders(methodBlock);
      generateRequest(methodBlock);
    }

    Statement returnStatement;
    if (!method.getReturnType().equals(MetaClassFactory.get(void.class))) {
      if (MetaClassFactory.get(Number.class).isAssignableFrom(method.getReturnType().asBoxed())) {
        returnStatement = Stmt.load(0).returnValue();
      }
      else if (MetaClassFactory.get(Boolean.class).isAssignableFrom(method.getReturnType().asBoxed())) {
View Full Code Here

   
    // TODO CookieParams
  }

  private void generateRequestBuilder(BlockBuilder<?> methodBlock) {
    Statement urlEncoder = Stmt.invokeStatic(URL.class, "encode", Stmt.loadVariable("url").invoke("toString"));

    Statement requestBuilder =
        Stmt.declareVariable("requestBuilder", RequestBuilder.class,
            Stmt.newObject(RequestBuilder.class)
                .withParameters(resourceMethod.getHttpMethod(), urlEncoder));

    methodBlock.append(requestBuilder);
View Full Code Here

    ContextualStatementBuilder sendRequest = Stmt.loadVariable("requestBuilder");
    if (resourceMethod.getParameters().getEntityParameter() == null) {
      sendRequest = sendRequest.invoke("sendRequest", null, generateRequestCallback());
    }
    else {
      Statement body = marshal(resourceMethod.getParameters().getEntityParameter());
      sendRequest = sendRequest.invoke("sendRequest", body, generateRequestCallback());
    }

    methodBlock.append(Stmt
        .try_()
View Full Code Here

        .append(errorHandling)
        .finish());
  }

  private Statement generateRequestCallback() {
    Statement requestCallback = Stmt
        .newObject(RequestCallback.class)
        .extend()
        .publicOverridesMethod("onError", Parameter.of(Request.class, "request"),
            Parameter.of(Throwable.class, "throwable"))
        .append(errorHandling)
View Full Code Here

    return classBuilder;
  }

  private void generateErrorHandler(ClassStructureBuilder<?> classBuilder) {
    Statement errorHandling = Stmt
      .if_(Bool.notEquals(Variable.get("errorCallback"), null))
      .append(Stmt.loadVariable("errorCallback").invoke("error", null, Variable.get("throwable")))
      .finish()
      .else_()
      .append(Stmt.invokeStatic(GWT.class, "log",
View Full Code Here

    if (!method.isPublic()) {
      instance.ensureMemberExposed();
    }

    final String parmClassName = parm.getType().getFullyQualifiedName();
    final Statement bus = instance.getInjectionContext().getInjector(MessageBus.class).getType(instance);
    final String subscribeMethodName = method.isAnnotationPresent(Local.class) ? "subscribeLocal" : "subscribe";

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

    return get(field.getDeclaringClass()).getDeclaredField(field.getName());
  }

  public static Statement getAsStatement(Class<?> clazz) {
    final MetaClass metaClass = createOrGet(clazz.getName(), false);
    return new Statement() {
      @Override
      public String generate(Context context) {
        return LoadClassReference.getClassReference(metaClass, context);
      }
View Full Code Here

        return name;
      }

      @Override
      public Statement getValue() {
        return new Statement() {

          String generatedCache;

          @Override
          public String generate(Context context) {
View Full Code Here

TOP

Related Classes of org.jboss.errai.codegen.framework.Statement

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.