本文整理匯總了Java中io.vertx.codegen.annotations.ModuleGen類的典型用法代碼示例。如果您正苦於以下問題:Java ModuleGen類的具體用法?Java ModuleGen怎麽用?Java ModuleGen使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ModuleGen類屬於io.vertx.codegen.annotations包,在下文中一共展示了ModuleGen類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolve
import io.vertx.codegen.annotations.ModuleGen; //導入依賴的package包/類
/**
* Resolve a module info for the specified {@code pkgElt} argument, returns null for undertermined.
*
* @param elementUtils the element utils
* @param pkgElt the package element
* @return the module info
*/
public static ModuleInfo resolve(Elements elementUtils, PackageElement pkgElt) {
String pkgQN = pkgElt.getQualifiedName().toString();
while (true) {
if (pkgElt != null) {
ModuleGen annotation = pkgElt.getAnnotation(ModuleGen.class);
if (annotation != null) {
return new ModuleInfo(pkgElt.getQualifiedName().toString(), annotation.name(), annotation.groupPackage());
}
}
int pos = pkgQN.lastIndexOf('.');
if (pos == -1) {
break;
} else {
pkgQN = pkgQN.substring(0, pos);
Set<PackageElement> pkgElts = getPackageElement.apply(elementUtils, pkgQN);
pkgElt = pkgElts.isEmpty() ? null : pkgElts.iterator().next();
}
}
return null;
}
示例2: resolveRelativeFileName
import io.vertx.codegen.annotations.ModuleGen; //導入依賴的package包/類
@Override
public String resolveRelativeFileName(PackageElement docElt, String relativeFileName) {
ModuleGen module;
PackageElement current = docElt;
while (true) {
module = current.getAnnotation(ModuleGen.class);
if (module != null) {
break;
} else {
String fqn = current.toString();
int index = fqn.lastIndexOf('.');
if (index == -1) {
return relativeFileName;
}
fqn = fqn.substring(0, index);
current = env.getElementUtils().getPackageElement(fqn);
if (current == null) {
return relativeFileName;
}
}
}
// Special case
String prefix = module.name();
if (prefix.equals("vertx")) {
prefix = "vertx-core";
}
return prefix + "/" + relativeFileName;
}
示例3: getSupportedAnnotationTypes
import io.vertx.codegen.annotations.ModuleGen; //導入依賴的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.ModuleGen; //導入依賴的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.ModuleGen; //導入依賴的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.ModuleGen; //導入依賴的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);
}
}