• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JMod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



JMod类属于com.helger.jcodemodel包,在下文中一共展示了JMod类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createFromMap

import com.helger.jcodemodel.JMod; //导入依赖的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: setOnRequestPermissionsResultMethod

import com.helger.jcodemodel.JMod; //导入依赖的package包/类
private void setOnRequestPermissionsResultMethod() {
    onRequestPermissionsResultMethod = holder().getGeneratedClass().method(JMod.PUBLIC, getCodeModel().VOID, "onRequestPermissionsResult");
    onRequestPermissionsResultMethod.annotate(Override.class);

    onRequestPermissionsResultRequestCodeParam = onRequestPermissionsResultMethod.param(getCodeModel().INT, "requestCode");
    JVar permissionsParam = onRequestPermissionsResultMethod.param(getJClass("java.lang.String").array(), "permissions");
    onRequestPermissionsResultGrantResultsParam = onRequestPermissionsResultMethod.param(getCodeModel().INT.array(), "grantResults");

    JBlock onRequestPermissionsResultMethodBody = onRequestPermissionsResultMethod.body();

    onRequestPermissionsResultMethodBody.invoke(JExpr._super(), "onRequestPermissionsResult")
            .arg(onRequestPermissionsResultRequestCodeParam)
            .arg(permissionsParam)
            .arg(onRequestPermissionsResultGrantResultsParam);

    onRequestPermissionsResultMethodDelegateBlock = onRequestPermissionsResultMethodBody.blockVirtual();

    onRequestPermissionsResultMethodBody.assign(getPermissionDispatcherCalledField(), JExpr.FALSE);
}
 
开发者ID:permissions-dispatcher,项目名称:AndroidAnnotationsPermissionsDispatcherPlugin,代码行数:20,代码来源:PermissionDispatcherHolder.java


示例3: buildFactory

import com.helger.jcodemodel.JMod; //导入依赖的package包/类
JMethod buildFactory(Map<String, JMethod> constructorMethods) throws JClassAlreadyExistsException {
    JDefinedClass factory = buildFactoryClass(constructorMethods);

    JFieldVar factoryField = environment.buildValueClassField(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, factory, "FACTORY");
    JAnnotationUse fieldAnnotationUse = factoryField.annotate(SuppressWarnings.class);
    JAnnotationArrayMember paramArray = fieldAnnotationUse.paramArray("value");
    paramArray.param("unchecked");
    paramArray.param("rawtypes");

    factoryField.init(JExpr._new(factory));
    JMethod factoryMethod = environment.buildValueClassMethod(Source.toJMod(environment.factoryMethodAccessLevel()) | JMod.STATIC, "factory");
    Source.annotateNonnull(factoryMethod);
    JAnnotationUse methodAnnotationUse = factoryMethod.annotate(SuppressWarnings.class);
    methodAnnotationUse.param("value", "unchecked");
    for (JTypeVar visitorTypeParameter: environment.getValueTypeParameters()) {
        JTypeVar typeParameter = factoryMethod.generify(visitorTypeParameter.name());
        typeParameter.boundLike(visitorTypeParameter);
    }
    AbstractJClass usedValueClassType = environment.wrappedValueClassType(factoryMethod.typeParams());
    factoryMethod.type(environment.visitor(usedValueClassType, usedValueClassType, types._RuntimeException).getVisitorType());
    factoryMethod.body()._return(factoryField);
    return factoryMethod;
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:24,代码来源:FinalValueClassModel.java


示例4: declareAcceptMethod

import com.helger.jcodemodel.JMod; //导入依赖的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


示例5: buildHashCodeCachedValueField

import com.helger.jcodemodel.JMod; //导入依赖的package包/类
private JFieldVar buildHashCodeCachedValueField(Serialization serialization) {
    if (!environment.hashCodeCaching().enabled())
        throw new IllegalStateException("Unsupported method evaluation to cache hash code: " + environment.hashCodeCaching());
    else {
        boolean isSerializable = serialization.isSerializable();
        boolean precomputes = environment.hashCodeCaching() == Caching.PRECOMPUTE;
        int mods = JMod.PRIVATE;
        mods = !isSerializable ? mods : mods | JMod.TRANSIENT;
        if (!precomputes)
            return environment.buildValueClassField(mods, types._int, "hashCodeCachedValue", JExpr.lit(0));
        else {
            mods = isSerializable ? mods : mods | JMod.FINAL;
            return environment.buildValueClassField(mods, types._int, "hashCodeCachedValue");
        }
    }
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:17,代码来源:FinalValueClassModel.java


示例6: buildProtectedConstructor

import com.helger.jcodemodel.JMod; //导入依赖的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


示例7: generatePredicate

import com.helger.jcodemodel.JMod; //导入依赖的package包/类
void generatePredicate(String name, PredicateConfigutation predicate) {
    JMethod predicateMethod = environment.buildValueClassMethod(Source.toJMod(predicate.accessLevel()) | JMod.FINAL, name);
    predicateMethod.type(types._boolean);
    if (isError) {
        predicateMethod.body()._throw(JExpr._new(types._UnsupportedOperationException));
    } else {
        JMethod implementation = environment.buildAcceptingInterfaceMethod(JMod.PUBLIC, name);
        implementation.type(types._boolean);

        predicateMethod.body()._return(JExpr.refthis(acceptorField).invoke(implementation));

        for (JMethod interfaceMethod1: environment.visitorDefinition().methodDefinitions()) {
            JDefinedClass caseClass = caseClasses.get(interfaceMethod1.name());
            predicateMethod = caseClass.method(JMod.PUBLIC | JMod.FINAL, types._boolean, name);
            predicateMethod.annotate(Override.class);

            boolean result = predicate.isTrueFor(interfaceMethod1);
            predicateMethod.body()._return(JExpr.lit(result));
        }
    }
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:22,代码来源:FinalValueClassModel.java


示例8: visitConstant_def

import com.helger.jcodemodel.JMod; //导入依赖的package包/类
@Override
public Void visitConstant_def(Constant_defContext ctx) {
    String constName = ctx.constant_name().IDENTIFIER().getText();
    String constType = ctx.constant_type().TYPE_LITERAL().getText();
    Literal_valueContext lit = ctx.literal_value();
    ProtoTypes type = ProtoTypes.valueOf( constType.toUpperCase() );

    ProtoContext pkgCtx = (ProtoContext) ctx.getParent();
    String pkg = pkgCtx.package_def().package_name().QUALIFIED_IDENTIFIER().getText();
    JDefinedClass container = codeModel._package( pkg )._getClass( containerName );

    int modifier = JMod.PUBLIC | JMod.STATIC | JMod.FINAL;
    AbstractJType jtype = primitiveType( type ).unboxify();

    JFieldVar f = container.field( modifier, jtype, constName.toUpperCase(), parse( type, container, lit ) );
    logger.info( "\t +-> {} {} = {}", f.type().name(), f.name(), lit.getText() );

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


示例9: visitEnum_def

import com.helger.jcodemodel.JMod; //导入依赖的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


示例10: createToMap

import com.helger.jcodemodel.JMod; //导入依赖的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


示例11: createSaveMethod

import com.helger.jcodemodel.JMod; //导入依赖的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


示例12: makeCall

import com.helger.jcodemodel.JMod; //导入依赖的package包/类
@Override
protected void makeCall(JBlock listenerMethodBody, JInvocation call, TypeMirror returnType) {
    JVar currentClickTime = listenerMethodBody.decl(JMod.NONE, JPrimitiveType.LONG, "currentClickMilliseconds", getCodeModel().directClass("android.os.SystemClock").staticInvoke("uptimeMillis"));
    JVar elapsedTime = listenerMethodBody.decl(JMod.NONE, JPrimitiveType.LONG, "elapsedMilliseconds", JOp.minus(currentClickTime, lastClickMilliseconds));
    listenerMethodBody._if(JOp.lte(elapsedTime, intervalTime))._then()._return();
    listenerMethodBody.assign(lastClickMilliseconds, currentClickTime);
    listenerMethodBody.add(call);
}
 
开发者ID:m0er,项目名称:androidannotations-interval-click-plugin,代码行数:9,代码来源:IntervalClickHandler.java


示例13: createAcceptingInterface

import com.helger.jcodemodel.JMod; //导入依赖的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


示例14: buildPrivateConstructor

import com.helger.jcodemodel.JMod; //导入依赖的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


示例15: buildAcceptMethod

import com.helger.jcodemodel.JMod; //导入依赖的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


示例16: buildReadObjectMethod

import com.helger.jcodemodel.JMod; //导入依赖的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


示例17: toJMod

import com.helger.jcodemodel.JMod; //导入依赖的package包/类
public static int toJMod(MemberAccess accessLevel) {
    switch (accessLevel) {
        case PRIVATE:
            return JMod.PRIVATE;
        case PACKAGE:
            return JMod.NONE;
        case PROTECTED:
            return JMod.PROTECTED;
        case PUBLIC:
            return JMod.PUBLIC;
        default:
            throw new IllegalStateException("Unsupported AccessLevel: " + accessLevel);
    }
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:15,代码来源:Source.java


示例18: createStage0Model

import com.helger.jcodemodel.JMod; //导入依赖的package包/类
public Stage0ValueClassModel createStage0Model(JDefinedClass bootModel, Visitor visitorAnnotation) {
    GenerationProcess generation = new GenerationProcess();
    JAnnotationUse annotation = null;
    for (JAnnotationUse anyAnnotation: bootModel.annotations()) {
        AbstractJClass annotationClass = anyAnnotation.getAnnotationClass();
        if (!annotationClass.isError()) {
            String fullName = annotationClass.fullName();
            if (fullName != null && fullName.equals(GenerateValueClassForVisitor.class.getName()))
                annotation = anyAnnotation;
        }
    }
    if (annotation == null)
        throw new IllegalStateException("ValueClassModelFactory can't be run for interface without " + GenerateValueClassForVisitor.class + " annotation");
    VisitorDefinition visitorModel = generation.processGenerationResult(VisitorDefinition.createInstance(bootModel, visitorAnnotation));
    ValueClassConfiguration configuration = generation.processGenerationResult(ValueClassConfiguration.createInstance(visitorModel, annotation));
    int mods = configuration.isValueClassPublic() ? JMod.PUBLIC: JMod.NONE;
    JDefinedClass valueClass;
    try {
        valueClass = factory.defineClass(bootModel._package().name(), mods, configuration.valueClassName());
    } catch (JClassAlreadyExistsException ex) {
        return new Stage0ValueClassModel("Class " + configuration.valueClassName() + " already exists");
    }
    JAnnotationUse generatedAnnotation = valueClass.annotate(Generated.class);
    generatedAnnotation.param("value", GenerateValueClassForVisitorProcessor.class.getName());
    Source.annotateParametersAreNonnullByDefault(valueClass);
    return new Stage0ValueClassModel(valueClass);
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:28,代码来源:Stage0ValueClassModelFactory.java


示例19: visitMessage_def

import com.helger.jcodemodel.JMod; //导入依赖的package包/类
@Override
public Void visitMessage_def(Message_defContext ctx) {
    try {
        boolean isError = ctx.messsage_type().ERROR_LITERAL() != null;
        String name = ctx.message_name().IDENTIFIER().getText();
        AbstractJClass parent = isError ? codeModel.ref( Exception.class ) : codeModel.ref( Object.class );
        ProtoContext pkgCtx = (ProtoContext) ctx.getParent();
        String pkg = pkgCtx.package_def().package_name().QUALIFIED_IDENTIFIER().getText();
        JPackage jPackage = codeModel._package( pkg );
        JDefinedClass m = jPackage._class( name );
        JDefinedClass container = jPackage._getClass( containerName );

        if ( ctx.message_parent() != null && ctx.message_parent().message_parent_message() != null ) {
            All_identifiersContext parentCtx = ctx.message_parent().message_parent_message().all_identifiers();
            parent = resolveType( container, parentCtx );
        }

        if ( parent != null ) {
            m._extends( parent );
        }
        container.field( JMod.PUBLIC | JMod.FINAL | JMod.STATIC, m, name, JExpr._new( m ) );
        addDenifition( container, m );

        JAnnotationUse generated = m.annotate( Generated.class );
        generated.param( "date", new Date().toString() );
        generated.paramArray( JAnnotationUse.SPECIAL_KEY_VALUE ).param( Generator.class.getName() );
        logger.info( "Message({}.{})", m._package().name(), m.name() );
        return super.visitMessage_def( ctx );
    }
    catch ( JClassAlreadyExistsException err ) {
        throw new RuntimeException( err );
    }
}
 
开发者ID:turbospaces,项目名称:protoc,代码行数:34,代码来源:Antlr4ProtoVisitor.java


示例20: visitService_method_def

import com.helger.jcodemodel.JMod; //导入依赖的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.JMod类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NumberInput类代码示例发布时间:2022-05-22
下一篇:
Java Version类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap