Package com.helger.jcodemodel

Examples of com.helger.jcodemodel.JInvocation


        JDefinedClass anonymousClass1 = valueClass.owner().anonymousClass(visitorType);
        GetterBody body = new GetterBody(configuration, anonymousClass1);
        for (JMethod interfaceMethod1: visitorInterface.methods()) {
            body.generateCase(interfaceMethod1);
        }
        JInvocation invocation1 = JExpr._this().invoke("accept");
        invocation1.arg(JExpr._new(anonymousClass1));
        getterMethod.body()._return(invocation1);
    }
View Full Code Here


        JDefinedClass anonymousClass1 = valueClass.owner().anonymousClass(visitorType);
        UpdaterBody body = new UpdaterBody(configuration, anonymousClass1, newValue, nameSource);
        for (JMethod interfaceMethod1: visitorInterface.methods()) {
            body.generateCase(interfaceMethod1);
        }
        JInvocation invocation1 = JExpr._this().invoke("accept");
        invocation1.arg(JExpr._new(anonymousClass1));
        updaterMethod.body()._return(invocation1);
    }
View Full Code Here

                }
            }
            visitorMethod1.body()._return(JExpr.lit(result));
        }

        JInvocation invocation1 = JExpr._this().invoke("accept");
        invocation1.arg(JExpr._new(anonymousClass1));
        predicateMethod.body()._return(invocation1);
    }
View Full Code Here

                    }
                    visitorMethod2.body()._return(JExpr.lit(0));
                }
            }

            JInvocation invocation2 = that.invoke("accept");
            invocation2.arg(JExpr._new(anonymousClass2));
            visitorMethod1.body()._return(invocation2);
        }
        JInvocation invocation1 = JExpr._this().invoke("accept");
        invocation1.arg(JExpr._new(anonymousClass1));
        compareToMethod.body()._return(invocation1);
    }
View Full Code Here

                    visitorMethod1.body()._return(argument);
                    isGettable = true;
                }
            }
            if (!isGettable) {
                JInvocation exceptionInvocation = JExpr._new(types._IllegalStateException);
                exceptionInvocation.arg(configuration.name() + " is not accessible in this case: " + interfaceMethod1.name());
                visitorMethod1.body()._throw(exceptionInvocation);
            }
        }
View Full Code Here

        private void generateCase(JMethod interfaceMethod1) {
            AbstractJClass usedValueClassType = valueClass.narrow(valueClass.typeParams());
            JMethod visitorMethod1 = visitor.method(interfaceMethod1.mods().getValue() & ~JMod.ABSTRACT, usedValueClassType, interfaceMethod1.name());
            visitorMethod1.annotate(Override.class);
            visitorMethod1.annotate(Nonnull.class);
            JInvocation invocation = valueClass.staticInvoke(interfaceMethod1.name());
            for (JTypeVar typeArgument: valueClass.typeParams())
                invocation.narrow(typeArgument);
            for (JVar param: interfaceMethod1.params()) {
                AbstractJType argumentType = visitorInterface.substituteSpecialType(param.type(), usedValueClassType, configuration.type().boxify(), types._RuntimeException);
                JVar argument = visitorMethod1.param(param.mods().getValue(), argumentType, nameSource.get(param.name()));
                if (configuration.isFieldValue(interfaceMethod1, param.name())) {
                    invocation.arg(newValue);
                } else {
                    invocation.arg(argument);
                }
            }
            JVar param = interfaceMethod1.listVarParam();
            if (param != null) {
                AbstractJType argumentType = visitorInterface.substituteSpecialType(param.type().elementType(), usedValueClassType, configuration.type().boxify(), types._RuntimeException);
                JVar argument = visitorMethod1.varParam(param.mods().getValue(), argumentType, nameSource.get(param.name()));
                if (configuration.isFieldValue(interfaceMethod1, param.name())) {
                    invocation.arg(newValue);
                } else {
                    invocation.arg(argument);
                }
            }
            visitorMethod1.body()._return(invocation);
        }
View Full Code Here

                else
                    forBody.appendNotNullValue(type.elementType(), value.component(i));
            } else if (!type.isPrimitive()) {
                appendNotNullValue(types._int, value.invoke("hashCode"));
            } else if (type.name().equals("double")) {
                JInvocation invocation = types._Double.staticInvoke("doubleToLongBits");
                invocation.arg(value);
                appendNotNullValue(types._long, invocation);
            } else if (type.name().equals("float")) {
                JInvocation invocation = types._Float.staticInvoke("floatToIntBits");
                invocation.arg(value);
                appendNotNullValue(types._int, invocation);
            } else if (type.name().equals("boolean")) {
                appendNotNullValue(types._int, JOp.cond(value, JExpr.lit(0), JExpr.lit(1)));
            } else if (type.name().equals("long")) {
                appendNotNullValue(types._int, JExpr.cast(types._int, value.xor(value.shrz(JExpr.lit(32)))));
View Full Code Here

            ifbody.appendNotNullValue(paramType, field1, field2);
        }

        void appendNotNullValue(AbstractJType type, IJExpression value1, IJExpression value2) {
            if (type.isArray()) {
                JInvocation invocation = types._Math.staticInvoke("min");
                invocation.arg(value1.ref("length"));
                invocation.arg(value2.ref("length"));
                JVar length = body.decl(types._int, nameSource.get("length"), invocation);
                VariableNameSource localNames = nameSource.forBlock();
                JForLoop _for = body._for();
                JVar i = _for.init(types._int, localNames.get("i"), JExpr.lit(0));
                _for.test(i.lt(length));
                _for.update(i.incr());
                Body forBody = new Body(resultVariable, _for.body(), localNames);
                if (type.elementType().isReference())
                    forBody.appendNullableValue(type.elementType(), value1.component(i), value2.component(i));
                else
                    forBody.appendNotNullValue(type.elementType(), value1.component(i), value2.component(i));
                appendNotNullValue(types._int, value1.ref("length"), value2.ref("length"));
            } else if (type.isPrimitive()) {
                IJExpression condition = JOp.cond(value1.lt(value2), JExpr.lit(-1),
                                                  JOp.cond(value1.eq(value2), JExpr.lit(0), JExpr.lit(1)));
                body.assign(resultVariable, condition);
                JConditional _if = body._if(resultVariable.ne(JExpr.lit(0)));
                _if._then()._return(resultVariable);
            } else {
                JInvocation invocation = value1.invoke("compareTo");
                invocation.arg(value2);
                body.assign(resultVariable, invocation);
                JConditional _if = body._if(resultVariable.ne(JExpr.lit(0)));
                _if._then()._return(resultVariable);
            }
        }
View Full Code Here

        this.body = body;
        this.result = result;
    }

    void appendParam(AbstractJType type, String name, IJExpression value) {
        JInvocation invocation = body.invoke(result, "append");
        invocation.arg(name + " = ");
        invocation = body.invoke(result, "append");
        invocation.arg(value);
    }
View Full Code Here

                forBody.appendNotNullValue(type.elementType(), value1.component(i), value2.component(i));
        } else if (type.isPrimitive()) {
            JConditional _if = body._if(value1.ne(value2));
            _if._then()._return(JExpr.FALSE);
        } else {
            JInvocation invocation = value1.invoke("equals");
            invocation.arg(value2);
            JConditional _if = body._if(invocation.not());
            _if._then()._return(JExpr.FALSE);
        }
    }
View Full Code Here

TOP

Related Classes of com.helger.jcodemodel.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.