Package com.sun.codemodel

Examples of com.sun.codemodel.JInvocation


        JVar var;
        if (!cls.isPrimitive() && nillable) {
            var = this.method.body().decl(model._ref(cls), name, JExpr._null());
            JConditional cond = this.method.body()._if(xsrVar.invoke("isXsiNil").not());
           
            JInvocation invocation = xsrVar.invoke(method);
            cond._then().assign(var, invocation);
        } else {
            var = this.method.body().decl(model._ref(cls), name, xsrVar.invoke(method));
        }
       
View Full Code Here


        ElementParserBuilderImpl b = new ElementParserBuilderImpl(this, false, name, methodNameHint);
        states.add(b);
       
        JMethod nextMethod = b.getMethod();
       
        JInvocation invocation = JExpr.invoke(nextMethod).arg(xsrVar).arg(rtContextVar);
        b.methodInvocation = invocation;
       
        block.add(invocation);
       
        return b;
View Full Code Here

        JBlock block = preElementBlock;
       
        ElementParserBuilderImpl b = (ElementParserBuilderImpl) builder;
        JMethod nextMethod = b.getMethod();
       
        JInvocation invocation = JExpr.invoke(nextMethod).arg(xsrVar).arg(rtContextVar);
        for (JVar v : b.variables) {
            invocation.arg(v);
        }

        varName = variableManager.createId(varName);
        return block.decl(type, varName, invocation);
    }
View Full Code Here

        JBlock readBlock = expected.getReadBlock();
        AbstractParserBuilder builder = expected.getParserBuilder();
        if (builder != null) {
            JMethod readMethod = builder.getMethod();

            JInvocation invocation = JExpr.invoke(readMethod).arg(xsrVar).arg(rtContextVar);

            // Global reader methods don't have arguments
            if (vars == null) vars = builder.getVariables();
            if (vars != null) {
                for (JExpression var : vars) {
                    invocation.arg(var);
                }
            }

            if (readBlock != null) {
                if (expected.getReadVar() != null) {
View Full Code Here

  protected void constructDeserializedObject( @NotNull DomainObjectDescriptor domainObjectDescriptor, @NotNull JMethod deserializeMethod, @NotNull Map<FieldWithInitializationInfo, JVar> fieldToVar ) {
    deserializeMethod.body().directStatement( "//Constructing the deserialized object" );

    //Now create the constructor for the deserializeMethod
    JClass domainType = codeGenerator.ref( domainObjectDescriptor.getQualifiedName() );
    JInvocation domainTypeInit = JExpr._new( domainType );

    //Add the arguments for the fields
    List<? extends FieldInitializedInConstructorInfo> fieldsToSerialize = domainObjectDescriptor.getFieldsInitializedInConstructor();
    for ( FieldInitializedInConstructorInfo fieldInfo : fieldsToSerialize ) {
      domainTypeInit.arg( fieldToVar.get( fieldInfo ) );
    }

    //Add the object type
    JVar domainObjectVar = deserializeMethod.body().decl( domainType, VAR_NAME_OBJECT, domainTypeInit );
View Full Code Here

            JFieldRef fr = JExpr.ref(fieldName);
           
            JExpression test;
            JConditional jc;
            JInvocation invocation;
                           
            invocation = JExpr.invoke("tryOverwrite");
            invocation.arg(JExpr.dotclass(type.boxify()));
            invocation.arg(JExpr.lit(fieldName));
            JVar tmp = method.body().decl(type.boxify(), "_" + fieldName,
                                          invocation);
            test = JOp.not(JOp.eq(JExpr._null(), tmp));
            jc = method.body()._if(test);
            jc._then()._return(tmp);
           
            test = JOp.not(JOp.eq(JExpr._null(), fr));
            jc = method.body()._if(test);
            jc._then()._return(fr);
           
            invocation = JExpr.invoke("tryFallback");
            invocation.arg(JExpr.dotclass(type.boxify()));
            invocation.arg(JExpr.lit(fieldName));
            // tmp = method.body().decl(type.boxify(), "_" + fieldName, invocation);
            method.body().assign(tmp, invocation);
            test = JOp.not(JOp.eq(JExpr._null(), tmp));
            jc = method.body()._if(test);
            jc._then()._return(tmp);
View Full Code Here

           
            // modify the setter to notify the property change
 
            JMethod method = dc.getMethod(setterName, new JType[] {type.boxify()});
            if (null != method) {
                JInvocation invocation = JExpr.invoke("notifyPropertyChange");
                invocation.arg(JExpr.lit(fieldName));
                method.body().add(invocation);
            }
        }
    }
View Full Code Here

    JClass mapType = codeModel.ref( Map.class ).narrow( Version.class, String.class );
    JClass hashMapType = codeModel.ref( HashMap.class ).narrow( Version.class, String.class );

    JVar map = method.body().decl( mapType, "map", JExpr._new( hashMapType ) );

    JInvocation invocation = map.invoke( "put" ).arg( versionRef.staticInvoke( "valueOf" ).arg( JExpr.lit( 1 ) ).arg( JExpr.lit( 0 ) ).arg( JExpr.lit( 0 ) ) ).arg( "<todo/>" );

    method.body().add( invocation );
    method.body()._return( map );
  }
View Full Code Here

  protected void constructDeserializedObject( @NotNull DomainObjectDescriptor domainObjectDescriptor, @NotNull JMethod deserializeMethod, @NotNull Map<FieldWithInitializationInfo, JVar> fieldToVar ) {
    deserializeMethod.body().directStatement( "//Constructing the deserialized object" );

    //Now create the constructor for the deserializeMethod
    JClass domainType = codeGenerator.ref( domainObjectDescriptor.getQualifiedName() );
    JInvocation domainTypeInit = JExpr._new( domainType );

    //Add the arguments for the fields
    List<? extends FieldInitializedInConstructorInfo> fieldsToSerialize = domainObjectDescriptor.getFieldsInitializedInConstructor();
    for ( FieldInitializedInConstructorInfo fieldInfo : fieldsToSerialize ) {
      domainTypeInit.arg( fieldToVar.get( fieldInfo ) );
    }

    //Add the object type
    JVar domainObjectVar = deserializeMethod.body().decl( domainType, VAR_NAME_OBJECT, domainTypeInit );
View Full Code Here

    JClass returnType = codeModel.ref( List.class ).narrow( codeModel.ref( String.class ).wildcard() );
    JMethod method = serializerTestClass.method( JMod.PROTECTED, returnType, METHOD_NAME_GET_EXPECTED_SERIALIZED );
    method.annotate( Override.class );


    JInvocation asListInvocation = codeModel.ref( Arrays.class ).staticInvoke( "asList" );
    for ( int i = 0; i < NUMBER_OF_OBJECTS; i++ ) {
      asListInvocation.arg( JExpr.lit( "<implementMe/>" ) );
    }

    method.body()._return( asListInvocation );
    return method;
  }
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.