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


Java SimpleAnnotationValueVisitor8类代码示例

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


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

示例1: convertToNameSpaceMappings

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
List<NameSpaceMapping> convertToNameSpaceMappings(AnnotationValue nameSpaceMappingAnnotationValue, Element element) {
    if (nameSpaceMappingAnnotationValue == null) return null;
    return new SimpleAnnotationValueVisitor8<List<NameSpaceMapping>, Void>() {
        @Override
        public List<NameSpaceMapping> visitArray(List<? extends AnnotationValue> vals, Void aVoid) {
            return vals.stream()
                    .map(x -> {
                        String value = (String) x.getValue();
                        Optional<NameSpaceMapping> result = splitIntoTwo(value).flatMap(y -> Optional.of(NameSpaceMappingBuilder.of(y.getFirst(), y.getSecond())));
                        if (!result.isPresent())
                            env.getMessager().printMessage(Diagnostic.Kind.ERROR, "param not valid. Expecting a name space mapping. Got:" + x, element);
                        return result;
                    })
                    .filter(Optional::isPresent)
                    .map(Optional::get)
                    .collect(Collectors.toList());
        }

    }.visit(nameSpaceMappingAnnotationValue);
}
 
开发者ID:dzuvic,项目名称:jtsgen,代码行数:21,代码来源:TSModuleHandler.java

示例2: convertExclusion

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
List<Pattern> convertExclusion(AnnotationValue exclAnnotationValue, Element element) {
    if (exclAnnotationValue == null) return null;
    return new SimpleAnnotationValueVisitor8<List<Pattern>, Void>() {
        @Override
        public List<Pattern> visitArray(List<? extends AnnotationValue> vals, Void aVoid) {
            return vals.stream()
                    .map(x -> {
                        String value = (String) x.getValue();
                        Optional<Pattern> result = compileToPattern(value);
                        if (!result.isPresent())
                            env.getMessager().printMessage(Diagnostic.Kind.ERROR, "param not valid. Expecting a regular Expression. Got:" + x, element);
                        return result;
                    })
                    .filter(Optional::isPresent)
                    .map(Optional::get)
                    .collect(Collectors.toList());
        }

    }.visit(exclAnnotationValue);
}
 
开发者ID:dzuvic,项目名称:jtsgen,代码行数:21,代码来源:TSModuleHandler.java

示例3: convertTypeMapping

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
Map<String, TSTargetType> convertTypeMapping(Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry) {
    AnnotationValue customMappingValue = entry.getValue();
    Element element = entry.getKey();
    if (customMappingValue == null) return new HashMap<>();
    List<TSTargetType> targetTypes = new SimpleAnnotationValueVisitor8<List<TSTargetType>, Void>() {
        @Override
        public List<TSTargetType> visitArray(List<? extends AnnotationValue> vals, Void aVoid) {
            return vals.stream()
                    .map(x -> {
                        String value = (String) x.getValue();
                        Either<String,TSTargetType> result = TSTargetFactory.createTSTargetByDSL(value);
                        if (result.isLeft())
                            env.getMessager().printMessage(Diagnostic.Kind.ERROR, "param not valid:" + x + "error: " + result.leftValue(), element);
                        return result.toOptional();
                    })
                    .filter(Optional::isPresent)
                    .map(Optional::get)
                    .collect(Collectors.toList());
        }
    }.visit(customMappingValue);

    return targetTypes.stream().filter(Objects::nonNull).collect(Collectors.toMap(TSTargetType::getJavaType, Function.identity()));
}
 
开发者ID:dzuvic,项目名称:jtsgen,代码行数:24,代码来源:TSModuleHandler.java

示例4: getTypesFromAnnotation

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
/**
 * At compile time classes can not be obtained from annotation directly.
 * This method extracts class information from annotation mirrors.
 *
 * @param element element annotated with {@link SqlSource} annotation
 * @param isReq   true for request, false for result parameters
 * @return list of class names from {@link SqlSource} annotation
 */
private List<String> getTypesFromAnnotation(Element element, boolean isReq) {
    TypeMirror sqlSourceTypeMirror = processingEnv.getElementUtils().getTypeElement(SqlSource.class.getName()).asType();
    //method names from SqlSource annotation
    String methodName = isReq ? "reqImpl" : "resImpl";
    List<? extends AnnotationMirror> annotationMirrors = element.getAnnotationMirrors();
    List<String> typeNames = new ArrayList<>();
    for (AnnotationMirror am : annotationMirrors) {
        if (!am.getAnnotationType().equals(sqlSourceTypeMirror)) {
            continue;
        }
        for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : am.getElementValues().entrySet()) {
            if (!methodName.equals(entry.getKey().getSimpleName().toString())) {
                continue;
            }
            AnnotationValue impResVal = entry.getValue();
            impResVal.accept(new SimpleAnnotationValueVisitor8<Void, Void>() {
                @Override
                public Void visitArray(List<? extends AnnotationValue> list, Void s) {
                    for (AnnotationValue val : list) {
                        TypeMirror typeMirror = (TypeMirror) val.getValue();
                        typeNames.add(typeMirror.toString());
                    }
                    return null;
                }
            }, null);
            break;
        }
    }
    return typeNames;
}
 
开发者ID:nds842,项目名称:sql-first-mapper,代码行数:39,代码来源:SqlFirstAnnotationProcessor.java

示例5: toBoolean

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
public static Boolean toBoolean(AnnotationValue value) {
    if (value == null) {
        return null;
    }
    return value.accept(new SimpleAnnotationValueVisitor8<Boolean, Void>() {

        @Override
        public Boolean visitBoolean(boolean b, Void p) {
            return b;
        }

    }, null);
}
 
开发者ID:domaframework,项目名称:doma,代码行数:14,代码来源:AnnotationValueUtil.java

示例6: toInteger

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
public static Integer toInteger(AnnotationValue value) {
    if (value == null) {
        return null;
    }
    return value.accept(new SimpleAnnotationValueVisitor8<Integer, Void>() {

        @Override
        public Integer visitInt(int i, Void p) {
            return i;
        }

    }, null);
}
 
开发者ID:domaframework,项目名称:doma,代码行数:14,代码来源:AnnotationValueUtil.java

示例7: toLong

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
public static Long toLong(AnnotationValue value) {
    if (value == null) {
        return null;
    }
    return value.accept(new SimpleAnnotationValueVisitor8<Long, Void>() {

        @Override
        public Long visitLong(long l, Void p) {
            return l;
        }

    }, null);
}
 
开发者ID:domaframework,项目名称:doma,代码行数:14,代码来源:AnnotationValueUtil.java

示例8: toString

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
public static String toString(AnnotationValue value) {
    if (value == null) {
        return null;
    }
    return value.accept(new SimpleAnnotationValueVisitor8<String, Void>() {

        @Override
        public String visitString(String s, Void p) {
            return s;
        }

    }, null);
}
 
开发者ID:domaframework,项目名称:doma,代码行数:14,代码来源:AnnotationValueUtil.java

示例9: toType

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
public static TypeMirror toType(AnnotationValue value) {
    if (value == null) {
        return null;
    }
    return value.accept(
            new SimpleAnnotationValueVisitor8<TypeMirror, Void>() {

                @Override
                public TypeMirror visitType(TypeMirror t, Void p) {
                    return t;
                }

            }, null);
}
 
开发者ID:domaframework,项目名称:doma,代码行数:15,代码来源:AnnotationValueUtil.java

示例10: toAnnotationMirror

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
public static AnnotationMirror toAnnotationMirror(AnnotationValue value) {
    if (value == null) {
        return null;
    }
    return value.accept(
            new SimpleAnnotationValueVisitor8<AnnotationMirror, Void>() {

                @Override
                public AnnotationMirror visitAnnotation(AnnotationMirror a,
                        Void p) {
                    return a;
                }

            }, null);
}
 
开发者ID:domaframework,项目名称:doma,代码行数:16,代码来源:AnnotationValueUtil.java

示例11: toEnumConstant

import javax.lang.model.util.SimpleAnnotationValueVisitor8; //导入依赖的package包/类
public static VariableElement toEnumConstant(AnnotationValue value) {
    if (value == null) {
        return null;
    }
    return value.accept(
            new SimpleAnnotationValueVisitor8<VariableElement, Void>() {

                @Override
                public VariableElement visitEnumConstant(VariableElement c,
                        Void p) {
                    return c;
                }

            }, null);
}
 
开发者ID:domaframework,项目名称:doma,代码行数:16,代码来源:AnnotationValueUtil.java


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