本文整理汇总了Java中io.vertx.codegen.annotations.VertxGen类的典型用法代码示例。如果您正苦于以下问题:Java VertxGen类的具体用法?Java VertxGen怎么用?Java VertxGen使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VertxGen类属于io.vertx.codegen.annotations包,在下文中一共展示了VertxGen类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testStringAnnotated
import io.vertx.codegen.annotations.VertxGen; //导入依赖的package包/类
@Test
public void testStringAnnotated() throws Exception {
ClassModel model = new Generator().generateClass(Annotated.class);
assertFalse(model.getAnnotations().isEmpty());
assertEquals(2, model.getAnnotations().size());
assertEquals(VertxGen.class.getName(), model.getAnnotations().get(0).getName());
assertEquals(EmptyAnnotation.class.getName(), model.getAnnotations().get(1).getName());
assertFalse(model.getMethodAnnotations().values().isEmpty());
assertEquals(1, model.getMethodAnnotations().get("stringAnnotated").size());
assertEquals(3, model.getMethodAnnotations().get("stringAnnotated").get(0).getMembersNames().size());
assertNotNull(model.getMethodAnnotations().get("stringAnnotated").get(0).getMember("value"));
assertNotNull(model.getMethodAnnotations().get("stringAnnotated").get(0).getMember("array"));
assertNotNull(model.getMethodAnnotations().get("stringAnnotated").get(0).getMember("defaultValue"));
assertEquals("aString", model.getMethodAnnotations().get("stringAnnotated").get(0).getMember("value"));
assertArrayEquals(new String[]{"one", "two"}, ((List) model.getMethodAnnotations().get("stringAnnotated").get(0).getMember("array")).toArray());
assertEquals("defaultString", model.getMethodAnnotations().get("stringAnnotated").get(0).getMember("defaultValue"));
}
示例2: getSupportedAnnotationTypes
import io.vertx.codegen.annotations.VertxGen; //导入依赖的package包/类
@Override
public Set<String> getSupportedAnnotationTypes() {
HashSet<String> set = new HashSet<>();
set.add(ProxyGen.class.getCanonicalName());
set.add(VertxGen.class.getCanonicalName());
set.add(DataObject.class.getCanonicalName());
set.add(ModuleGen.class.getCanonicalName());
return set;
}
示例3: CodeGen
import io.vertx.codegen.annotations.VertxGen; //导入依赖的package包/类
CodeGen(ProcessingEnvironment env, RoundEnvironment round, ClassLoader loader) {
this.env = env;
this.messager = env.getMessager();
this.elementUtils = env.getElementUtils();
this.typeUtils = env.getTypeUtils();
loaderMap.put(env, loader);
Predicate<Element> implFilter = elt -> {
String fqn = elementUtils.getPackageOf(elt).getQualifiedName().toString();
if (fqn.contains(".impl.") || fqn.endsWith(".impl")) {
logger.warning("Processed element " + elt + " is in an implementation package");
return false;
} else {
return true;
}
};
round.getElementsAnnotatedWith(DataObject.class).
stream().
filter(implFilter).
forEach(element -> dataObjects.put(Helper.getNonGenericType(element.asType().toString()), (TypeElement) element));
round.getElementsAnnotatedWith(VertxGen.class).
stream().
filter(implFilter).
filter(elt -> elt.getKind() != ElementKind.ENUM).
forEach(element -> classes.put(Helper.getNonGenericType(element.asType().toString()), (TypeElement) element));
round.getElementsAnnotatedWith(VertxGen.class).
stream().
filter(implFilter).
filter(elt -> elt.getKind() == ElementKind.ENUM).
forEach(element -> enums.put(Helper.getNonGenericType(element.asType().toString()), (TypeElement) element));
round.getElementsAnnotatedWith(ModuleGen.class).
stream().
map(element -> (PackageElement) element).
forEach(element -> modules.put(element.getQualifiedName().toString(), element));
round.getElementsAnnotatedWith(ProxyGen.class).
stream().
filter(implFilter).
forEach(element -> proxyClasses.put(Helper.getNonGenericType(element.asType().toString()), (TypeElement) element));
}
示例4: getSupportedAnnotationTypes
import io.vertx.codegen.annotations.VertxGen; //导入依赖的package包/类
@Override
public Set<String> getSupportedAnnotationTypes() {
return Arrays.asList(
VertxGen.class,
ProxyGen.class,
DataObject.class,
DataObject.class,
ModuleGen.class
).stream().map(Class::getName).collect(Collectors.toSet());
}
示例5: create
import io.vertx.codegen.annotations.VertxGen; //导入依赖的package包/类
public static TypeInfo create(Type type) {
if (type == void.class) {
return VoidTypeInfo.INSTANCE;
} else if (type instanceof Class) {
String fqcn = type.getTypeName();
Class<?> classType = (Class<?>) type;
if (classType.isPrimitive()) {
return PrimitiveTypeInfo.PRIMITIVES.get(classType.getName());
} else {
Package pkg = classType.getPackage();
ModuleInfo module = null;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classType.getClassLoader());
try {
while (pkg != null) {
ModuleGen annotation = pkg.getAnnotation(ModuleGen.class);
if (annotation != null) {
module = new ModuleInfo(pkg.getName(), annotation.name(), annotation.groupPackage());
break;
} else {
int pos = pkg.getName().lastIndexOf('.');
if (pos == -1) {
break;
} else {
pkg = Package.getPackage(pkg.getName().substring(0, pos));
}
}
}
} finally {
Thread.currentThread().setContextClassLoader(loader);
}
if (classType.isEnum()) {
return new EnumTypeInfo(
fqcn,
classType.getDeclaredAnnotation(VertxGen.class) != null,
Stream.of(classType.getEnumConstants()).map(Object::toString).collect(Collectors.toList()),
module,
false,
false);
} else {
ClassKind kind = ClassKind.getKind(fqcn, classType.getAnnotation(DataObject.class) != null, classType.getAnnotation(VertxGen.class) != null);
List<TypeParamInfo.Class> typeParams = new ArrayList<>();
int index = 0;
for (java.lang.reflect.TypeVariable<? extends Class<?>> var : classType.getTypeParameters()) {
typeParams.add(new TypeParamInfo.Class(classType.getName(), index++, var.getName()));
}
if (kind == ClassKind.API) {
java.lang.reflect.TypeVariable<Class<ReadStream>> classTypeVariable = ReadStream.class.getTypeParameters()[0];
Type readStreamArg = Helper.resolveTypeParameter(type, classTypeVariable);
return new ApiTypeInfo(fqcn, true, typeParams, readStreamArg != null ? create(readStreamArg) : null, null, null, module, false, false);
} else if (kind == ClassKind.DATA_OBJECT) {
boolean _abstract = Modifier.isAbstract(classType.getModifiers());
return new DataObjectTypeInfo(kind, fqcn, module, _abstract, false, false, typeParams);
} else {
return new ClassTypeInfo(kind, fqcn, module, false, typeParams);
}
}
}
} else if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
List<TypeInfo> args = Arrays.asList(parameterizedType.getActualTypeArguments()).
stream().
map(TypeReflectionFactory::create).
collect(Collectors.toList());
Type raw = parameterizedType.getRawType();
return new ParameterizedTypeInfo((ClassTypeInfo) create(raw), false, args);
} else if (type instanceof java.lang.reflect.TypeVariable) {
java.lang.reflect.TypeVariable typeVar = (java.lang.reflect.TypeVariable) type;
TypeParamInfo param = TypeParamInfo.create(typeVar);
return new TypeVariableInfo(param, false, ((java.lang.reflect.TypeVariable)type).getName());
} else {
throw new IllegalArgumentException("Unsupported type " + type);
}
}
示例6: create
import io.vertx.codegen.annotations.VertxGen; //导入依赖的package包/类
public TypeInfo create(TypeUse use, DeclaredType type) {
boolean nullable = use != null && use.isNullable();
TypeElement elt = (TypeElement) type.asElement();
PackageElement pkgElt = elementUtils.getPackageOf(elt);
ModuleInfo module = ModuleInfo.resolve(elementUtils, pkgElt);
String fqcn = elt.getQualifiedName().toString();
boolean proxyGen = elt.getAnnotation(ProxyGen.class) != null;
if (elt.getKind() == ElementKind.ENUM) {
ArrayList<String> values = new ArrayList<>();
for (Element enclosedElt : elt.getEnclosedElements()) {
if (enclosedElt.getKind() == ElementKind.ENUM_CONSTANT) {
values.add(enclosedElt.getSimpleName().toString());
}
}
boolean gen = elt.getAnnotation(VertxGen.class) != null;
return new EnumTypeInfo(fqcn, gen, values, module, nullable, proxyGen);
} else {
ClassKind kind = ClassKind.getKind(fqcn, elt.getAnnotation(DataObject.class) != null, elt.getAnnotation(VertxGen.class) != null);
ClassTypeInfo raw;
if (kind == ClassKind.BOXED_PRIMITIVE) {
raw = ClassTypeInfo.PRIMITIVES.get(fqcn);
if (nullable) {
raw = new ClassTypeInfo(raw.kind, raw.name, raw.module, true, raw.params);
}
} else {
List<TypeParamInfo.Class> typeParams = createTypeParams(type);
if (kind == ClassKind.API) {
VertxGen genAnn = elt.getAnnotation(VertxGen.class);
TypeInfo[] args = Stream.of(
ClassModel.VERTX_READ_STREAM,
ClassModel.VERTX_WRITE_STREAM,
ClassModel.VERTX_HANDLER
).map(s -> {
TypeElement parameterizedElt = elementUtils.getTypeElement(s);
TypeMirror parameterizedType = parameterizedElt.asType();
TypeMirror rawType = typeUtils.erasure(parameterizedType);
if (typeUtils.isSubtype(type, rawType)) {
TypeMirror resolved = Helper.resolveTypeParameter(typeUtils, type, parameterizedElt.getTypeParameters().get(0));
if (resolved.getKind() == TypeKind.DECLARED) {
DeclaredType dt = (DeclaredType) resolved;
TypeElement a = (TypeElement) dt.asElement();
if (a.getQualifiedName().toString().equals("io.vertx.core.AsyncResult")) {
return null;
}
}
return create(resolved);
}
return null;
}).toArray(TypeInfo[]::new);
raw = new ApiTypeInfo(fqcn, genAnn.concrete(), typeParams, args[0], args[1], args[2], module, nullable, proxyGen);
} else if (kind == ClassKind.DATA_OBJECT) {
boolean _abstract = elt.getModifiers().contains(Modifier.ABSTRACT);
raw = new DataObjectTypeInfo(kind, fqcn, module, _abstract, nullable, proxyGen, typeParams);
} else {
raw = new ClassTypeInfo(kind, fqcn, module, nullable, typeParams);
}
}
List<? extends TypeMirror> typeArgs = type.getTypeArguments();
if (typeArgs.size() > 0) {
List<TypeInfo> typeArguments;
typeArguments = new ArrayList<>(typeArgs.size());
for (int i = 0; i < typeArgs.size(); i++) {
TypeUse argUse = use != null ? use.getArg(fqcn, i) : null;
TypeInfo typeArgDesc = create(argUse, typeArgs.get(i));
// Need to check it is an interface type
typeArguments.add(typeArgDesc);
}
return new ParameterizedTypeInfo(raw, nullable, typeArguments);
} else {
return raw;
}
}
}
示例7: someMethod
import io.vertx.codegen.annotations.VertxGen; //导入依赖的package包/类
void someMethod(String str, Handler<AsyncResult<VertxGen>> wrongResultType);
示例8: someMethod
import io.vertx.codegen.annotations.VertxGen; //导入依赖的package包/类
void someMethod(VertxGen vertxGen);
示例9: someMethod
import io.vertx.codegen.annotations.VertxGen; //导入依赖的package包/类
VertxGen someMethod();