当前位置: 首页>>代码示例>>Java>>正文


Java JMethod.param方法代码示例

本文整理汇总了Java中com.helger.jcodemodel.JMethod.param方法的典型用法代码示例。如果您正苦于以下问题:Java JMethod.param方法的具体用法?Java JMethod.param怎么用?Java JMethod.param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.helger.jcodemodel.JMethod的用法示例。


在下文中一共展示了JMethod.param方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFromMap

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
private void createFromMap(JCodeModel codeModel, JDefinedClass genClazz) {
    JMethod fromMap = genClazz.method(JMod.PUBLIC | JMod.STATIC, genClazz, "fromMap");
    fromMap.param(codeModel.directClass(Map.class.getCanonicalName()).narrow(String.class).narrow(Object.class), "obj");
    fromMap.body().directStatement("return obj != null ? new " + genClazz.name() + "(obj) : null;");

    JMethod fromMapList = genClazz.method(JMod.PUBLIC | JMod.STATIC, codeModel.directClass(List.class.getCanonicalName()).narrow(genClazz), "fromMap");
    fromMapList.param(codeModel.directClass(List.class.getCanonicalName()).narrow(codeModel.directClass(Map.class.getCanonicalName()).narrow(String.class).narrow(Object.class)), "obj");

    StringBuilder mBuilder = new StringBuilder()
            .append("if(obj != null) { \n")
            .append("java.util.List<" + genClazz.name() + "> result = new java.util.ArrayList<" + genClazz.name() + ">(); \n")
            .append("for(java.util.Map<String, Object> entry : obj) { \n")
            .append("result.add(new " + genClazz.name() + "(entry)); \n")
            .append("} \n")
            .append("return result; \n")
            .append("} \n")
            .append("return null; \n");


    fromMapList.body().directStatement(mBuilder.toString());
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:22,代码来源:EntityGeneration.java

示例2: declareAcceptMethod

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
private JMethod declareAcceptMethod(JDefinedClass caseClass, AbstractJClass usedValueClassType) {
    JMethod acceptMethod = caseClass.method(JMod.PUBLIC, types._void, environment.acceptMethodName());
    acceptMethod.annotate(Override.class);
    JTypeVar visitorResultTypeParameter = environment.visitorDefinition().getResultTypeParameter();
    AbstractJClass resultType;
    if (visitorResultTypeParameter == null)
        resultType = types._Object;
    else {
        JTypeVar resultTypeVar = acceptMethod.generify(visitorResultTypeParameter.name());
        resultTypeVar.boundLike(visitorResultTypeParameter);
        resultType = resultTypeVar;
    }
    acceptMethod.type(resultType);
    JTypeVar visitorExceptionTypeParameter = environment.visitorDefinition().getExceptionTypeParameter();
    JTypeVar exceptionType = null;
    if (visitorExceptionTypeParameter != null) {
        JTypeVar exceptionTypeParameter = acceptMethod.generify(visitorExceptionTypeParameter.name());
        exceptionTypeParameter.boundLike(visitorExceptionTypeParameter);
        exceptionType = exceptionTypeParameter;
        acceptMethod._throws(exceptionType);
    }
    VisitorDefinition.VisitorUsage usedVisitorType = environment.visitor(usedValueClassType, resultType, exceptionType);
    acceptMethod.param(usedVisitorType.getVisitorType(), "visitor");
    return acceptMethod;
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:26,代码来源:FinalValueClassModel.java

示例3: buildProtectedConstructor

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
void buildProtectedConstructor(Serialization serialization) {
    JMethod constructor = environment.buildValueClassConstructor(JMod.PROTECTED);
    JAnnotationUse annotation = constructor.annotate(SuppressWarnings.class);
    annotation.paramArray("value", "null");
    AbstractJClass unwrappedUsedValueClassType = environment.unwrappedValueClassTypeInsideValueClass();
    JVar param = constructor.param(unwrappedUsedValueClassType, "implementation");
    Source.annotateNonnull(param);
    if (isError) {
        constructor.body()._throw(JExpr._new(types._UnsupportedOperationException));
    } else {
        JConditional nullCheck = constructor.body()._if(JExpr.ref("implementation").eq(JExpr._null()));
        JInvocation nullPointerExceptionConstruction = JExpr._new(types._NullPointerException);
        nullPointerExceptionConstruction.arg(JExpr.lit("Argument shouldn't be null: 'implementation' argument in class constructor invocation: " + environment.valueClassQualifiedName()));
        nullCheck._then()._throw(nullPointerExceptionConstruction);

        if (environment.hashCodeCaching().enabled())
            constructor.body().assign(JExpr.refthis(hashCodeCachedValueField), param.ref(hashCodeCachedValueField));
        constructor.body().assign(JExpr.refthis(acceptorField), param.ref(acceptorField));
    }
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:21,代码来源:FinalValueClassModel.java

示例4: visitEnum_def

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
@Override
public Void visitEnum_def(Enum_defContext ctx) {
    try {
        String name = ctx.enum_name().IDENTIFIER().getText();
        ProtoContext pkgCtx = (ProtoContext) ctx.getParent();
        String pkg = pkgCtx.package_def().package_name().QUALIFIED_IDENTIFIER().getText();
        JPackage jPackage = codeModel._package( pkg );
        JDefinedClass m = codeModel._package( pkg )._enum( name );
        JDefinedClass container = jPackage._getClass( containerName );

        String tag = "tag";
        m.field( JMod.PUBLIC | JMod.FINAL, codeModel.INT, tag );

        JMethod constructor = m.constructor( JMod.PRIVATE );
        constructor.param( codeModel.INT, tag );
        constructor.body().assign( JExpr._this().ref( tag ), JExpr.ref( tag ) );

        addDenifition( container, m );

        logger.info( "Enum({}.{})", m._package().name(), m.name() );
        return super.visitEnum_def( ctx );
    }
    catch ( JClassAlreadyExistsException err ) {
        throw new RuntimeException( err );
    }
}
 
开发者ID:turbospaces,项目名称:protoc,代码行数:27,代码来源:Antlr4ProtoVisitor.java

示例5: createToMap

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
private void createToMap(JCodeModel codeModel, JDefinedClass genClazz) {

        JMethod toMap = genClazz.method(JMod.PUBLIC | JMod.STATIC, codeModel.directClass(HashMap.class.getCanonicalName()).narrow(String.class).narrow(Object.class), "toMap");
        toMap.param(genClazz, "obj");

        StringBuilder builderSingle = new StringBuilder();
        builderSingle.append("if(obj == null){ \n");
        builderSingle.append("return null; \n");
        builderSingle.append("} \n");
        builderSingle.append("java.util.HashMap<String, Object> result = new java.util.HashMap<String, Object>(); \n");
        builderSingle.append("result.putAll(obj.mDoc); \n");
        builderSingle.append("result.putAll(obj.mDocChanges);\n");
        builderSingle.append("return result;\n");
        toMap.body().directStatement(builderSingle.toString());

        JMethod toMapList = genClazz.method(JMod.PUBLIC | JMod.STATIC, codeModel.directClass(List.class.getCanonicalName()).narrow(codeModel.directClass(HashMap.class.getCanonicalName()).narrow(String.class).narrow(Object.class)), "toMap");
        toMapList.param(codeModel.directClass(List.class.getCanonicalName()).narrow(genClazz), "obj");

        StringBuilder builderMulti = new StringBuilder();
        builderMulti.append("if(obj == null) return null; \n");
        builderMulti.append("java.util.List<java.util.HashMap<String, Object>> result = new java.util.ArrayList<java.util.HashMap<String, Object>>(); \n");
        builderMulti.append("for(" + genClazz.name() + " entry : obj) {\n");
        builderMulti.append("result.add(((" + genClazz.name() + ")entry).toMap(entry));\n");
        builderMulti.append("}\n");
        builderMulti.append("return result;\n");
        toMapList.body().directStatement(builderMulti.toString());
    }
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:28,代码来源:EntityGeneration.java

示例6: processParameters

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
@Override
protected void processParameters(EComponentWithViewSupportHolder holder, JMethod listenerMethod, JInvocation call, List<? extends VariableElement> parameters) {
    boolean hasItemParameter = parameters.size() == 1;

    JVar viewParam = listenerMethod.param(getClasses().VIEW, "view");

    if (hasItemParameter) {
        call.arg(castArgumentIfNecessary(holder, CanonicalNameConstants.VIEW, viewParam, parameters.get(0)));
    }
}
 
开发者ID:m0er,项目名称:androidannotations-interval-click-plugin,代码行数:11,代码来源:IntervalClickHandler.java

示例7: createAcceptingInterface

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
private JDefinedClass createAcceptingInterface() throws JClassAlreadyExistsException {
    JDefinedClass acceptingInterface = valueClass._class(JMod.PUBLIC, valueClass.name() + "Acceptor", EClassType.INTERFACE);

    // Hack to overcome bug in codeModel. We want private interface!!! Not public.
    acceptingInterface.mods().setPrivate();

    for (JTypeVar visitorTypeParameter: configuration.getValueTypeParameters()) {
        JTypeVar typeParameter = acceptingInterface.generify(visitorTypeParameter.name());
        typeParameter.boundLike(visitorTypeParameter);
    }

    JMethod acceptMethod = acceptingInterface.method(JMod.PUBLIC, types._void, configuration.acceptMethodName());

    JTypeVar visitorResultType = configuration.visitorDefinition().getResultTypeParameter();
    AbstractJClass resultType;
    if (visitorResultType == null)
        resultType = types._Object;
    else {
        JTypeVar resultTypeVar = acceptMethod.generify(visitorResultType.name());
        resultTypeVar.boundLike(visitorResultType);
        resultType = resultTypeVar;
    }
    acceptMethod.type(resultType);

    JTypeVar visitorExceptionType = configuration.visitorDefinition().getExceptionTypeParameter();
    JTypeVar exceptionType = null;
    if (visitorExceptionType != null) {
        JTypeVar exceptionTypeParameter = acceptMethod.generify(visitorExceptionType.name());
        exceptionTypeParameter.boundLike(visitorExceptionType);
        exceptionType = exceptionTypeParameter;
        acceptMethod._throws(exceptionType);
    }

    AbstractJClass usedValueClassType = Source.narrowType(valueClass, valueClass.typeParams());
    VisitorDefinition.VisitorUsage usedVisitorType = configuration.visitorDefinition().narrowed(usedValueClassType, resultType, exceptionType);
    acceptMethod.param(usedVisitorType.getVisitorType(), "visitor");

    return acceptingInterface;
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:40,代码来源:Stage1ValueClassModel.java

示例8: buildPrivateConstructor

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
void buildPrivateConstructor() {
    if (!isError) {
        JMethod constructor = environment.buildValueClassConstructor(JMod.PRIVATE);
        JVar acceptorParam = constructor.param(acceptorField.type(), acceptorField.name());
        if (environment.hashCodeCaching() == Caching.PRECOMPUTE) {
            JInvocation invocation = acceptorParam.invoke(hashCodeAcceptorMethodName());
            constructor.body().assign(JExpr.refthis(hashCodeCachedValueField), invocation);
        }
        constructor.body().assign(JExpr.refthis(acceptorField.name()), acceptorParam);
    }
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:12,代码来源:FinalValueClassModel.java

示例9: buildAcceptMethod

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
void buildAcceptMethod() {
    JMethod acceptMethod = environment.buildValueClassMethod(Source.toJMod(environment.acceptMethodAccessLevel()) | JMod.FINAL, environment.acceptMethodName());

    JTypeVar visitorResultTypeParameter = environment.visitorDefinition().getResultTypeParameter();
    AbstractJClass resultType;
    if (visitorResultTypeParameter == null)
        resultType = types._Object;
    else {
        JTypeVar resultTypeVar = acceptMethod.generify(visitorResultTypeParameter.name());
        resultTypeVar.boundLike(visitorResultTypeParameter);
        resultType = resultTypeVar;
    }
    acceptMethod.type(resultType);

    JTypeVar visitorExceptionTypeParameter = environment.visitorDefinition().getExceptionTypeParameter();
    JTypeVar exceptionType = null;
    if (visitorExceptionTypeParameter != null) {
        JTypeVar exceptionTypeVar = acceptMethod.generify(visitorExceptionTypeParameter.name());
        exceptionTypeVar.boundLike(visitorExceptionTypeParameter);
        exceptionType = exceptionTypeVar;
        acceptMethod._throws(exceptionType);
    }

    AbstractJClass usedValueClassType = environment.wrappedValueClassTypeInsideValueClass();
    VisitorDefinition.VisitorUsage usedVisitorType = environment.visitor(usedValueClassType, resultType, exceptionType);
    acceptMethod.param(usedVisitorType.getVisitorType(), "visitor");
    if (isError) {
        acceptMethod.body()._throw(JExpr._new(types._UnsupportedOperationException));
    } else {
        JInvocation invocation = acceptorField.invoke(environment.acceptMethodName());
        invocation.arg(JExpr.ref("visitor"));
        acceptMethod.body()._return(invocation);
    }
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:35,代码来源:FinalValueClassModel.java

示例10: buildReadObjectMethod

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
void buildReadObjectMethod() {
    if (!isError && environment.hashCodeCaching() == Caching.PRECOMPUTE) {
        JMethod method = environment.buildValueClassMethod(JMod.PRIVATE, "readObject");
        method._throws(types._IOException);
        method._throws(types._ClassNotFoundException);
        VariableNameSource variableNameSource = new VariableNameSource();
        JVar inputStream = method.param(types._ObjectInputStream, variableNameSource.get("input"));
        JBlock body = method.body();
        body.invoke(inputStream, "defaultReadObject");
        JInvocation invocation = JExpr.refthis(acceptorField).invoke(hashCodeAcceptorMethodName());
        body.assign(JExpr.refthis(hashCodeCachedValueField), invocation);
    }
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:14,代码来源:FinalValueClassModel.java

示例11: visitService_method_def

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
@Override
public Void visitService_method_def(Service_method_defContext ctx) {
    String methodName = ctx.service_method_name().IDENTIFIER().getText();
    ProtoContext pkgCtx = (ProtoContext) ctx.getParent().getParent();
    String pkg = pkgCtx.package_def().package_name().QUALIFIED_IDENTIFIER().getText();
    JPackage jPackage = codeModel._package( pkg );
    JDefinedClass container = jPackage._getClass( containerName );

    Service_defContext sCtx = (Service_defContext) ctx.getParent();
    String serviceName = sCtx.service_name().IDENTIFIER().getText();
    JDefinedClass service = jPackage._getClass( serviceName );

    Collection_map_valueContext reqCtx = ctx.service_method_req().collection_map_value();
    AbstractJClass respType = resolveType( container, ctx.service_method_resp().collection_map_value() );
    AbstractJClass reqType = null;

    JMethod m = service.method( JMod.PUBLIC, respType, methodName );
    if ( reqCtx != null ) {
        reqType = resolveType( container, reqCtx );
        m.param( reqType, "var" );
    }

    List<Service_method_excpContext> excpCtxs = ctx.service_method_throws().service_method_excp();
    for ( Service_method_excpContext excpCtx : excpCtxs ) {
        AbstractJClass exception = resolveType( container, excpCtx.all_identifiers() );
        m._throws( exception );
    }

    logger.info( "\t +-> {}({}) -> {}", m.name(), ( reqType != null ? reqType.name() : "" ), respType.name() );

    return super.visitService_method_def( ctx );
}
 
开发者ID:turbospaces,项目名称:protoc,代码行数:33,代码来源:Antlr4ProtoVisitor.java


注:本文中的com.helger.jcodemodel.JMethod.param方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。