本文整理汇总了Java中io.vertx.codegen.annotations.ProxyGen类的典型用法代码示例。如果您正苦于以下问题:Java ProxyGen类的具体用法?Java ProxyGen怎么用?Java ProxyGen使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProxyGen类属于io.vertx.codegen.annotations包,在下文中一共展示了ProxyGen类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findServiceInterfaces
import io.vertx.codegen.annotations.ProxyGen; //导入依赖的package包/类
void findServiceInterfaces(@Observes @WithAnnotations(ProxyGen.class) ProcessAnnotatedType<?> event, BeanManager beanManager) {
AnnotatedType<?> annotatedType = event.getAnnotatedType();
if (annotatedType.isAnnotationPresent(ProxyGen.class) && annotatedType.getJavaClass().isInterface()) {
LOGGER.debug("Service interface {0} discovered", annotatedType.getJavaClass());
serviceInterfaces.add(annotatedType.getJavaClass());
}
}
示例2: getInterface
import io.vertx.codegen.annotations.ProxyGen; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> Class<T> getInterface(Class<?> serviceClass) {
if (serviceClass.isAnnotationPresent(ProxyGen.class)) {
return (Class<T>) serviceClass;
}
Class<?>[] interfaces = serviceClass.getInterfaces();
for (Class<?> someInterface : interfaces) {
if (someInterface.isAnnotationPresent(ProxyGen.class)) { // it must be it
return (Class<T>) someInterface;
}
}
return null;
}
示例3: getSupportedAnnotationTypes
import io.vertx.codegen.annotations.ProxyGen; //导入依赖的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;
}
示例4: CodeGen
import io.vertx.codegen.annotations.ProxyGen; //导入依赖的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));
}
示例5: getSupportedAnnotationTypes
import io.vertx.codegen.annotations.ProxyGen; //导入依赖的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());
}
示例6: create
import io.vertx.codegen.annotations.ProxyGen; //导入依赖的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;
}
}
}