本文整理汇总了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);
}
示例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);
}
示例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()));
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}