本文整理匯總了Java中javax.lang.model.util.ElementFilter.requiresIn方法的典型用法代碼示例。如果您正苦於以下問題:Java ElementFilter.requiresIn方法的具體用法?Java ElementFilter.requiresIn怎麽用?Java ElementFilter.requiresIn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.lang.model.util.ElementFilter
的用法示例。
在下文中一共展示了ElementFilter.requiresIn方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getModuleRequires
import javax.lang.model.util.ElementFilter; //導入方法依賴的package包/類
/**
* Returns the "requires" modules for the target module.
* @param mdle the target module element
* @param onlyTransitive true gets all the requires transitive, otherwise
* gets all the non-transitive requires
*
* @return a set of modules
*/
private Set<ModuleElement> getModuleRequires(ModuleElement mdle, boolean onlyTransitive) throws ToolException {
Set<ModuleElement> result = new HashSet<>();
for (RequiresDirective rd : ElementFilter.requiresIn(mdle.getDirectives())) {
ModuleElement dep = rd.getDependency();
if (result.contains(dep))
continue;
if (!isMandated(mdle, rd) && onlyTransitive == rd.isTransitive()) {
if (!haveModuleSources(dep)) {
messager.printWarning(dep, "main.module_not_found", dep.getSimpleName());
}
result.add(dep);
} else if (isMandated(mdle, rd) && haveModuleSources(dep)) {
result.add(dep);
}
}
return result;
}
示例2: process
import javax.lang.model.util.ElementFilter; //導入方法依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
ModuleElement m2Module = processingEnv.getElementUtils().getModuleElement("m2x");
if (m2Module == null) {
throw new AssertionError("Cannot find the m2x module!");
}
boolean foundM1 = false;
for (RequiresDirective rd : ElementFilter.requiresIn(m2Module.getDirectives())) {
foundM1 |= rd.getDependency().getSimpleName().contentEquals("m1x");
}
if (!foundM1) {
throw new AssertionError("Cannot find the dependency on m1x module!");
}
return false;
}
示例3: process
import javax.lang.model.util.ElementFilter; //導入方法依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> u, RoundEnvironment r) {
ModuleElement sm = processingEnv.getElementUtils().getModuleElement("service");
if (sm == null) {
throw new AssertionError("Cannot find the service module!");
}
boolean foundjd = false;
for (RequiresDirective rd : ElementFilter.requiresIn(sm.getDirectives())) {
foundjd |= rd.getDependency().getQualifiedName().contentEquals("java.desktop");
}
if (!foundjd) {
throw new AssertionError("Missing dependency on java desktop module!");
}
return false;
}