本文整理汇总了Java中org.kohsuke.MetaInfServices类的典型用法代码示例。如果您正苦于以下问题:Java MetaInfServices类的具体用法?Java MetaInfServices怎么用?Java MetaInfServices使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetaInfServices类属于org.kohsuke包,在下文中一共展示了MetaInfServices类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContract
import org.kohsuke.MetaInfServices; //导入依赖的package包/类
private TypeElement getContract(TypeElement type, MetaInfServices a) {
// explicitly specified?
try {
a.value();
throw new AssertionError();
} catch (MirroredTypeException e) {
TypeMirror m = e.getTypeMirror();
if (m.getKind()== TypeKind.VOID) {
// contract inferred from the signature
boolean hasBaseClass = type.getSuperclass().getKind()!=TypeKind.NONE && !isObject(type.getSuperclass());
boolean hasInterfaces = !type.getInterfaces().isEmpty();
if(hasBaseClass^hasInterfaces) {
if(hasBaseClass)
return (TypeElement)((DeclaredType)type.getSuperclass()).asElement();
return (TypeElement)((DeclaredType)type.getInterfaces().get(0)).asElement();
}
error(type, "Contract type was not specified, but it couldn't be inferred.");
return null;
}
if (m instanceof DeclaredType) {
DeclaredType dt = (DeclaredType) m;
return (TypeElement)dt.asElement();
} else {
error(type, "Invalid type specified as the contract");
return null;
}
}
}