1 回答
TA贡献1784条经验 获得超9个赞
你可以看看 org.netbeans.modules.java.hints.jdk.mapreduce.PreconditionsChecker
private boolean isIterbale(ExpressionTree expression) {
TypeMirror tm = workingCopy.getTrees().getTypeMirror(TreePath.getPath(workingCopy.getCompilationUnit(), expression));
if (!Utilities.isValidType(tm)) {
return false;
}
if (tm.getKind() == TypeKind.ARRAY) {
return false;
} else {
tm = workingCopy.getTypes().erasure(tm);
TypeElement typeEl = workingCopy.getElements().getTypeElement("java.util.Collection");
if (typeEl != null) {
TypeMirror collection = typeEl.asType();
collection = workingCopy.getTypes().erasure(collection);
if (this.workingCopy.getTypes().isSubtype(tm, collection)) {
return true;
}
}
}
return false;
}
先决条件检查器
添加回答
举报