Examples of TernaryStatement


Examples of org.jboss.errai.codegen.TernaryStatement

      else if (dataType.isEntityType()) {
        // generate this:
        // entityManager.find(Key.fromJson(entityManager, candidate.get(${propertyPath}).isObject(), false), NO_SIDE_EFFECTS);

        // FIXME running a query that uses this in a where clause will be an O(N^2) operation on the number of entities. :-(
        return new TernaryStatement(
            Bool.notEquals(Stmt.loadVariable("candidate").invoke("get", dotNode.getPropertyPath()).invoke("isNull"), null),
            Stmt.loadLiteral(null),
            Stmt.loadVariable("entityManager").invoke("find",
                Stmt.invokeStatic(Key.class, "fromJsonObject",
                    Stmt.loadVariable("entityManager"),
View Full Code Here

Examples of org.jboss.errai.codegen.TernaryStatement

            Stmt.nestedCall(objStatement)
                    .invoke("get", SerializationParts.ENUM_STRING_VALUE).invoke("isString").invoke("stringValue"));

    final Statement falseStatement =
      (valStatement != null) ?
        new TernaryStatement(Bool.isNotNull(Stmt.nestedCall(valStatement).invoke("isString")),
            Stmt.invokeStatic(Enum.class, "valueOf", toType,
                Stmt.nestedCall(valStatement).invoke("isString").invoke("stringValue")),
            Stmt.load(null))
       : Stmt.load(null);

    return new TernaryStatement(Bool.isNotNull(objStatement), trueStatement, falseStatement);
  }
View Full Code Here

Examples of org.jboss.errai.codegen.TernaryStatement

    final Implementations.StringBuilderBuilder internalSBB = Implementations.newStringBuilder()
            .append("{\"" + SerializationParts.ENCODED_TYPE
                    + "\":\"" + toType.getFullyQualifiedName() + "\",\"" + SerializationParts.ENUM_STRING_VALUE + "\":\"")
            .append(Stmt.nestedCall(valueStatement).invoke("name")).append("\"}");

    final TernaryStatement ternaryStatement = new TernaryStatement(
            Bool.isNotNull(valueStatement), internalSBB, Stmt.load("null"));

    return sb.append(ternaryStatement);
  }
View Full Code Here

Examples of org.jboss.errai.codegen.TernaryStatement

      ContextualStatementBuilder s = null;
      if (type.isPrimitive()) {
        s = Stmt.nestedCall(Stmt.newObject(type.asBoxed()).withParameters(statement)).invoke("toString");
      }
      else {
        s = Stmt.nestedCall(new TernaryStatement(Bool.isNull(statement), Stmt.load(""), Stmt.nestedCall(statement)));
        if (!type.equals(MetaClassFactory.get(String.class))) {
          s = s.invoke("toString");
        }
      }
View Full Code Here

Examples of org.jboss.errai.codegen.TernaryStatement

            Stmt.nestedCall(objStatement)
                    .invoke("get", SerializationParts.ENUM_STRING_VALUE).invoke("isString").invoke("stringValue"));

    final Statement falseStatement =
      (valStatement != null) ?
        new TernaryStatement(Bool.isNotNull(Stmt.nestedCall(valStatement).invoke("isString")),
            Stmt.invokeStatic(Enum.class, "valueOf", toType,
                Stmt.nestedCall(valStatement).invoke("isString").invoke("stringValue")),
            Stmt.load(null))
       : Stmt.load(null);

    return new TernaryStatement(Bool.isNotNull(objStatement), trueStatement, falseStatement);
  }
View Full Code Here

Examples of org.jboss.errai.codegen.TernaryStatement

    final Implementations.StringBuilderBuilder internalSBB = Implementations.newStringBuilder()
            .append("{\"" + SerializationParts.ENCODED_TYPE
                    + "\":\"" + toType.getFullyQualifiedName() + "\",\"" + SerializationParts.ENUM_STRING_VALUE + "\":\"")
            .append(Stmt.nestedCall(valueStatement).invoke("name")).append("\"}");

    final TernaryStatement ternaryStatement = new TernaryStatement(
            Bool.isNotNull(valueStatement), internalSBB, Stmt.load("null"));

    return sb.append(ternaryStatement);
  }
View Full Code Here

Examples of org.jboss.errai.codegen.TernaryStatement

      else if (dataType.isEntityType()) {
        // generate this:
        // entityManager.find(Key.fromJson(entityManager, candidate.get(${propertyPath}).isObject(), false), NO_SIDE_EFFECTS);

        // FIXME running a query that uses this in a where clause will be an O(N^2) operation on the number of entities. :-(
        return new TernaryStatement(
            Bool.notEquals(Stmt.loadVariable("candidate").invoke("get", dotNode.getPropertyPath()).invoke("isNull"), null),
            Stmt.loadLiteral(null),
            Stmt.loadVariable("entityManager").invoke("find",
                Stmt.invokeStatic(Key.class, "fromJsonObject",
                    Stmt.loadVariable("entityManager"),
View Full Code Here

Examples of org.jboss.errai.codegen.TernaryStatement

        Stmt.nestedCall(objStatement)
            .invoke("get", SerializationParts.ENUM_STRING_VALUE).invoke("isString").invoke("stringValue"));

    final Statement falseStatement =
        (valStatement != null) ?
            new TernaryStatement(Bool.isNotNull(Stmt.nestedCall(valStatement).invoke("isString")),
                Stmt.invokeStatic(Enum.class, "valueOf", toType,
                    Stmt.nestedCall(valStatement).invoke("isString").invoke("stringValue")),
                Stmt.load(null))
            : Stmt.load(null);

    return new TernaryStatement(Bool.isNotNull(objStatement), trueStatement, falseStatement);
  }
View Full Code Here

Examples of org.jboss.errai.codegen.TernaryStatement

    final Implementations.StringBuilderBuilder internalSBB = Implementations.newStringBuilder()
        .append("{\"" + SerializationParts.ENCODED_TYPE
            + "\":\"" + toType.getFullyQualifiedName() + "\",\"" + SerializationParts.ENUM_STRING_VALUE + "\":\"")
        .append(Stmt.nestedCall(valueStatement).invoke("name")).append("\"}");

    final TernaryStatement ternaryStatement = new TernaryStatement(
        Bool.isNotNull(valueStatement), internalSBB, Stmt.load("null"));

    bb.invoke("append", ternaryStatement);
  }
View Full Code Here

Examples of org.jboss.errai.codegen.TernaryStatement

      return loadVariable("a0").invoke(method);
    }
  }

  public Statement demarshallEnum(Statement valueStatement, MetaClass toType) {
    TernaryStatement ternaryStatement = new TernaryStatement(Bool.isNotNull(valueStatement),
            Stmt.invokeStatic(Enum.class, "valueOf", toType, Stmt.nestedCall(valueStatement)
                    .invoke("get", SerializationParts.ENUM_STRING_VALUE).invoke("isString").invoke("stringValue")),
            Stmt.load(null));

    return ternaryStatement;
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.