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


Java AbstractJClass.isError方法代码示例

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


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

示例1: readGetter

import com.helger.jcodemodel.AbstractJClass; //导入方法依赖的package包/类
GenerationResult<Void> readGetter(MethodUsage interfaceMethod, VariableDeclaration param, AbstractJType paramType, boolean isVarArg) {
    GenerationProcess generation = new GenerationProcess();
    for (JAnnotationUse annotationUsage: param.annotations()) {
        AbstractJClass annotationClass = annotationUsage.getAnnotationClass();
        if (!annotationClass.isError()) {
            String annotationClassName = annotationClass.fullName();
            if (annotationClassName != null && annotationClassName.equals(Getter.class.getName())) {
                String getterName = annotationUsage.getParam("name", String.class);
                if (getterName == null || getterName.equals(":auto"))
                    getterName = param.name();
                MemberAccess accessLevel = annotationUsage.getParam("access", MemberAccess.class);
                boolean isNullable = Source.isNullable(param);
                FieldFlags flags = new FieldFlags(isNullable, isVarArg, accessLevel);
                FieldConfiguration configuration = new FieldConfiguration(getterName, paramType, flags);
                generation.processGenerationResult(read(interfaceMethod, param, configuration));
            }
        }
    }
    return generation.<Void>createGenerationResult(null);
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:21,代码来源:FieldReader.java

示例2: readUpdater

import com.helger.jcodemodel.AbstractJClass; //导入方法依赖的package包/类
GenerationResult<Void> readUpdater(MethodUsage interfaceMethod, VariableDeclaration param, AbstractJType paramType, boolean isVarArg) {
    GenerationProcess generation = new GenerationProcess();
    for (JAnnotationUse annotationUsage: param.annotations()) {
        AbstractJClass annotationClass = annotationUsage.getAnnotationClass();
        if (!annotationClass.isError()) {
            String annotationClassName = annotationClass.fullName();
            if (annotationClassName != null && annotationClassName.equals(Updater.class.getName())) {
                String updaterName = annotationUsage.getParam("name", String.class);
                if (updaterName == null || updaterName.equals(":auto"))
                    updaterName = "with" + Source.capitalize(param.name());
                MemberAccess accessLevel = annotationUsage.getParam("access", MemberAccess.class);
                boolean isNullable = Source.isNullable(param);
                FieldFlags flags = new FieldFlags(isNullable, isVarArg, accessLevel);
                FieldConfiguration configuration = new FieldConfiguration(updaterName, paramType, flags);
                generation.processGenerationResult(read(interfaceMethod, param, configuration));
            }
        }
    }
    return generation.<Void>createGenerationResult(null);
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:21,代码来源:FieldReader.java

示例3: getNullability

import com.helger.jcodemodel.AbstractJClass; //导入方法依赖的package包/类
public static GenerationResult<Boolean> getNullability(AbstractJType type, String name, Collection<? extends JAnnotationUse> annotations) {
    boolean hasNonnull = false;
    boolean hasNullable = false;
    for (JAnnotationUse annotationUse: annotations) {
        AbstractJClass annotationClass = annotationUse.getAnnotationClass();
        if (!annotationClass.isError()) {
            String annotationClassName = annotationClass.fullName();
            if (annotationClassName != null) {
                if (annotationClassName.equals("javax.annotation.Nonnull")) {
                    hasNonnull = true;
                }
                if (annotationClassName.equals("javax.annotation.Nullable")) {
                    hasNullable = true;
                }
            }
        }
    }
    if (hasNonnull && hasNullable)
        return new GenerationResult<>(false, Collections.singletonList(MessageFormat.format("Parameter {0} is declared as both @Nullable and @Nonnull",
                                                       name)));
    if (!type.isReference() && hasNullable)
        return new GenerationResult<>(false, Collections.singletonList(MessageFormat.format("Parameter {0} is non-reference, but declared as @Nullable",
                                                       name)));
    return new GenerationResult<>(hasNullable, Collections.<String>emptyList());
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:26,代码来源:Source.java

示例4: createStage1Model

import com.helger.jcodemodel.AbstractJClass; //导入方法依赖的package包/类
public GenerationResult<Stage1ValueClassModel> createStage1Model(JDefinedClass jVisitorModel, Visitor visitorAnnotation) {
    GenerationProcess generation = new GenerationProcess();
    if (error != null) {
        generation.reportError(error);
        return generation.createGenerationResult(null);
    } else {
        JAnnotationUse annotation = null;
        for (JAnnotationUse anyAnnotation: jVisitorModel.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(jVisitorModel, visitorAnnotation));
        ValueClassConfiguration configuration = generation.processGenerationResult(ValueClassConfiguration.createInstance(visitorModel, annotation, valueClass));
        Stage1ValueClassModel result = createStage1Model(configuration);
        return generation.createGenerationResult(result);
    }
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:24,代码来源:Stage0ValueClassModel.java

示例5: createStage0Model

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

示例6: createMethodMap

import com.helger.jcodemodel.AbstractJClass; //导入方法依赖的package包/类
private static GenerationResult<Map<String, JMethod>> createMethodMap(JDefinedClass jVisitorModel,
                                                    SpecialTypeVariables specialTypeVariables) {
    GenerationProcess generation = new GenerationProcess();
    Map<String, JMethod> methods = new TreeMap<>();
    for (JMethod method: jVisitorModel.methods()) {
        AbstractJType methodType = method.type();
        if (methodType == null)
            generation.reportError(MessageFormat.format("Visitor method result type is missing: {0}", method.name()));
        else if (methodType.isError()) {
            generation.reportError(MessageFormat.format("Visitor method result type is erroneous: {0}", method.name()));
        } else if (!specialTypeVariables.isResult(method.type())) {
            generation.reportError(MessageFormat.format("Visitor method is only allowed to return type declared as a result type of visitor: {0}: expecting {1}, found: {2}",
                    method.name(), specialTypeVariables.resultTypeParameter().name(), methodType.fullName()));
        }
        for (JTypeVar typeVariable: method.typeParamList()) {
            for (AbstractJClass bound: typeVariable.bounds()) {
                if (bound.containsTypeVar(specialTypeVariables.resultTypeParameter())) {
                    generation.reportError(MessageFormat.format("Visitor method type-parameters shouldn''t depend on result type: {0}: {1} type-variable",
                            method.name(), typeVariable.name()));
                }
            }
        }
        for (JVar parameter: method.listParams()) {
            if (parameter.type().containsTypeVar(specialTypeVariables.resultTypeParameter())) {
                generation.reportError(MessageFormat.format("Visitor method shouldn''t have result type as a parameter: {0}: result type-parameter: {1}",
                        method.name(), specialTypeVariables.resultTypeParameter().name()));
            }
        }

        Collection<AbstractJClass> exceptions = method.getThrows();
        if (exceptions.size() > 1)
            generation.reportError(MessageFormat.format("Visitor method is allowed to throw no exceptions or throw single exception, declared as type-variable: {0}",
                    method.name()));
        else if (exceptions.size() == 1) {
            AbstractJClass exception = exceptions.iterator().next();
            if (exception.isError())
                generation.reportError(MessageFormat.format("Visitor method exception type is erroneous: {0}", method.name()));
            else if (!specialTypeVariables.isException(exception))
                generation.reportError(MessageFormat.format("Visitor method throws exception, not declared as type-variable: {0}: {1}",
                    method.name(), exception.fullName()));
        }

        JMethod exitingValue = methods.put(method.name(), method);
        if (exitingValue != null) {
            generation.reportError(MessageFormat.format("Method overloading is not supported for visitor interfaces: two methods with the same name: {0}",
                                                method.name()));
        }
        for (JVar param: method.params()) {
            generation.processGenerationResult(Source.getNullability(param));
        }
    }
    return generation.createGenerationResult(methods);
}
 
开发者ID:sviperll,项目名称:adt4j,代码行数:54,代码来源:VisitorDefinition.java


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