Package com.sun.codemodel

Examples of com.sun.codemodel.JInvocation


  @Nonnull
  public Expressions createReadFromDeserializeFromExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, JVar wrapper, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) {
    JClass collectionParamType = codeGenerator.ref( fieldInfo.getCollectionParam().toString() );
    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JInvocation expression = JExpr.invoke( METHOD_NAME_DESERIALIZE ).arg( JExpr.dotclass( collectionParamType ) ).arg( constant ).arg( deserializeFrom ).arg( formatVersion );
    return new Expressions( expression );
  }
View Full Code Here


  @Override
  @Nonnull
  public JInvocation createAddToSerializeToExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression serializeTo, @Nonnull FieldDeclarationInfo fieldInfo, @Nonnull JVar object, JVar formatVersion ) {
    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JInvocation getter = codeGenerator.createGetterInvocation( object, fieldInfo );

    if ( fieldInfo.isType( String.class ) ) {
      return serializeTo.invoke( "writeStringField" )
        .arg( constant )
        .arg( getter );
View Full Code Here

  @Override
  public Expressions createReadFromDeserializeFromExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, JVar wrapper, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) {
    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JClass type = codeGenerator.ref( TypeUtils.getErasure( fieldInfo.getType() ).toString() );
    JInvocation expression = JExpr.invoke( METHOD_NAME_DESERIALIZE ).arg( JExpr.dotclass( type ) ).arg( constant ).arg( formatVersion ).arg( deserializeFrom );
    return new Expressions( expression );
  }
View Full Code Here

  @Nonnull
  public JExpression createCollectionInvocation( @Nonnull JType collectionParamType, @Nonnull String simpleName, boolean isSet ) {
    JExpression expression = create( collectionParamType.erasure(), simpleName );

    JInvocation listInvocation = classRefSupport.ref( Arrays.class ).staticInvoke( METHOD_NAME_AS_LIST ).arg( expression );
    if ( isSet ) {
      return JExpr._new( classRefSupport.ref( HashSet.class ) ).arg( listInvocation );
    } else {
      return listInvocation;
    }
View Full Code Here

  @Nonnull
  public JExpression createCollectionInvocation( @Nonnull TypeMirror collectionParamType, @Nonnull String simpleName, boolean isSet ) {
    JExpression expression = create( TypeUtils.getErasure( collectionParamType ), simpleName );

    JInvocation listInvocation = classRefSupport.ref( Arrays.class ).staticInvoke( METHOD_NAME_AS_LIST ).arg( expression );
    if ( isSet ) {
      return JExpr._new( classRefSupport.ref( HashSet.class ) ).arg( listInvocation );
    } else {
      return listInvocation;
    }
View Full Code Here

      boolean isVoidMethod = method.getReturnType() == void.class;
      for(JBlock b : blocks[i++]) {
        if(!b.isEmpty()) {
          if (blocksInMethod > MAX_BLOCKS_IN_FUNCTION) {
            JMethod inner = clazz.method(JMod.PRIVATE, model._ref(method.getReturnType()), method.getMethodName() + methodIndex);
            JInvocation methodCall = JExpr.invoke(inner);
            for(CodeGeneratorArgument arg : method){
              inner.param(arg.getType(), arg.getName());
              methodCall.arg(JExpr.direct(arg.getName()));
            }
            for(Class<?> c : method.getThrowsIterable()){
              inner._throws(model.ref(c));
            }
            inner._throws(SchemaChangeException.class);
View Full Code Here

    JVar complexWriter = g.declareClassField("complexWriter", g.getModel()._ref(ComplexWriter.class));

    JClass cwClass = g.getModel().ref(ComplexWriterImpl.class);
   
    JInvocation container = g.getMappingSet().getOutgoing().invoke("getOutgoingContainer");
 
    //Default name is "col", if not passed in a reference name for the output vector.
    String refName = ref == null? "col" : ref.getRootSegment().getPath();
   
    g.getSetupBlock().assign(complexWriter, cwClass.staticInvoke("getWriter").arg(refName).arg(container));
View Full Code Here

      } else {
        String setMethod = e.isSafe() ? "setSafe" : "set";

        String isSafeMethod = "isSafe";

        JInvocation setMeth;
        if (Types.usesHolderForGet(inputContainer.getMajorType())) {
          setMeth = vv.invoke("getMutator").invoke(setMethod).arg(outIndex).arg(inputContainer.getHolder());
        } else {
          setMeth = vv.invoke("getMutator").invoke(setMethod).arg(outIndex).arg(inputContainer.getValue());
        }

        if (e.isSafe()) {
          HoldingContainer outputContainer = generator.declare(Types.REQUIRED_BIT);
          block.assign(outputContainer.getValue(), JExpr.lit(1));
          if (inputContainer.isOptional()) {
            // block._if(vv.invoke("getMutator").invoke(setMethod).arg(outIndex).not())._then().assign(outputContainer.getValue(),
            // JExpr.lit(0));
            JConditional jc = block._if(inputContainer.getIsSet().eq(JExpr.lit(0)).not());
            block = jc._then();
            jc._else()._if(vv.invoke("getMutator").invoke(isSafeMethod).arg(outIndex).not())._then()
                .assign(outputContainer.getValue(), JExpr.lit(0));
          }
          block._if(setMeth.not())._then().assign(outputContainer.getValue(), JExpr.lit(0));
          return outputContainer;
        } else {
          if (inputContainer.isOptional()) {
            // block.add(vv.invoke("getMutator").invoke(setMethod).arg(outIndex));
            JConditional jc = block._if(inputContainer.getIsSet().eq(JExpr.lit(0)).not());
View Full Code Here

      for (int i = 1; i < fieldIds.length; i++) {

      }

      if (!hasReadPath && !complex) {
        JInvocation getValueAccessor = vv1.invoke("getAccessor").invoke("get");
        JInvocation getValueAccessor2 = vv1.invoke("getAccessor");
        JBlock eval = new JBlock();

        if (primitive) {
          eval.assign(out.getValue(), getValueAccessor.arg(indexVariable));
        } else {
          eval.add(getValueAccessor.arg(indexVariable).arg(out.getHolder()));
        }

        if (out.isOptional()) {
          JBlock blk = generator.getEvalBlock();
          blk.assign(out.getIsSet(), getValueAccessor2.invoke("isSet").arg(indexVariable));
          JConditional jc = blk._if(out.getIsSet().eq(JExpr.lit(1)));
          jc._then().add(eval);
        } else {
          generator.getEvalBlock().add(eval);
        }
View Full Code Here

    JVar[] internalVars = new JVar[workspaceJVars.length];   
    for(int i =0; i < workspaceJVars.length; i++){
      //sub.assign(workspaceJVars[i], JExpr._new(g.getHolderType(workspaceVars[i].majorType)));
      //Access workspaceVar through workspace vector.        
      JInvocation getValueAccessor = g.getWorkspaceVectors().get(workspaceVars[i]).invoke("getAccessor").invoke("get");         
      if (Types.usesHolderForGet(workspaceVars[i].majorType)) {
        sub.add(getValueAccessor.arg(wsIndexVariable).arg(workspaceJVars[i]));
      } else {
        sub.assign(workspaceJVars[i].ref("value"), getValueAccessor.arg(wsIndexVariable));
      }
      internalVars[i] = sub.decl(g.getHolderType(workspaceVars[i].majorType),  workspaceVars[i].name, workspaceJVars[i]);                   
    }
   
    Preconditions.checkNotNull(body);
    sub.directStatement(body);
    JVar successVar = sub.decl(JType.parse(g.getModel(), "boolean"), "success", JExpr.lit(false));
   
    // reassign workspace variables back.
    for(int i =0; i < workspaceJVars.length; i++){
      sub.assign(workspaceJVars[i], internalVars[i]);
     
      //Change workspaceVar through workspace vector.    
      JInvocation setMeth;
      if (Types.usesHolderForGet(workspaceVars[i].majorType)) {
        setMeth = g.getWorkspaceVectors().get(workspaceVars[i]).invoke("getMutator").invoke("setSafe").arg(wsIndexVariable).arg(workspaceJVars[i]);
      }else{
        setMeth = g.getWorkspaceVectors().get(workspaceVars[i]).invoke("getMutator").invoke("setSafe").arg(wsIndexVariable).arg(workspaceJVars[i].ref("value"));
      }
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JInvocation

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.