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


Java JMethod._throws方法代码示例

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


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

示例1: 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

示例2: createSaveMethod

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
private void createSaveMethod(JCodeModel codeModel, JDefinedClass genClazz, List<CblFieldHolder> attachments, List<CblConstantHolder> constantFields) {
    JMethod mSave = genClazz.method(JMod.PUBLIC, codeModel.VOID, "save");
    mSave._throws(CouchbaseLiteException.class);

    StringBuilder builder = new StringBuilder();
    builder.append("com.couchbase.lite.Document doc = kaufland.com.coachbasebinderapi.PersistenceConfig.getInstance().createOrGet(getId()); \n");

    for (CblConstantHolder constant : constantFields) {
        builder.append("mDocChanges.put(\"" + constant.getDbField() + "\",\"" + constant.getConstantValue() + "\"); \n");
    }

    builder.append("java.util.HashMap<String, Object> temp = new java.util.HashMap<String, Object>(); \n");
    builder.append("if(doc.getProperties() != null){ \n");
    builder.append("temp.putAll(doc.getProperties()); \n");
    builder.append("} \n");
    builder.append("if(mDocChanges != null){ \n");
    builder.append("temp.putAll(mDocChanges); \n");
    builder.append("} \n");
    builder.append("doc.putProperties(temp); \n");

    if (attachments.size() > 0) {

        builder.append("com.couchbase.lite.UnsavedRevision rev = doc.createRevision(); \n");
        for (CblFieldHolder attachment : attachments) {

            builder.append("if(" + attachment.getDbField() + " != null){ \n");
            builder.append("rev.setAttachment(\"" + attachment.getDbField() + "\", \"" + attachment.getAttachmentType() + "\", " + attachment.getDbField() + "); \n");
            builder.append("} \n");
        }
        builder.append("rev.save(); \n");
    }
    builder.append("rebind(doc.getProperties()); \n");

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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: createGetterBodyAttachment

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
private void createGetterBodyAttachment(AbstractJClass resturnValue, String dbField, JMethod getter) {


        getter._throws(CouchbaseLiteException.class);
        StringBuilder builder = new StringBuilder();

        builder.append("com.couchbase.lite.Document doc = kaufland.com.coachbasebinderapi.PersistenceConfig.getInstance().createOrGet(getId()); \n");

        builder.append("if(doc.getCurrentRevision() != null && doc.getCurrentRevision().getAttachments() != null &&  doc.getCurrentRevision().getAttachments().size() > 0) {\n");
        builder.append("return doc.getCurrentRevision().getAttachments().get(0).getContent(); \n");
        builder.append("} \n");
        builder.append("return null; \n");

        getter.body().directStatement(builder.toString());

    }
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:17,代码来源:EntityGeneration.java

示例8: createDeleteMethod

import com.helger.jcodemodel.JMethod; //导入方法依赖的package包/类
private void createDeleteMethod(JCodeModel codeModel, JDefinedClass genClazz) {
    JMethod delete = genClazz.method(JMod.PUBLIC, codeModel.VOID, "delete");
    delete._throws(CouchbaseLiteException.class);
    delete.body().directStatement("kaufland.com.coachbasebinderapi.PersistenceConfig.getInstance().createOrGet(getId()).delete();");
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:6,代码来源:EntityGeneration.java


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