本文整理汇总了Java中com.google.common.collect.Iterators.filter方法的典型用法代码示例。如果您正苦于以下问题:Java Iterators.filter方法的具体用法?Java Iterators.filter怎么用?Java Iterators.filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Iterators
的用法示例。
在下文中一共展示了Iterators.filter方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getScriptErrors
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
protected List<Diagnostic> getScriptErrors(Script script) {
EcoreUtil.resolveAll(script.eResource());
List<Diagnostic> diagnostics = super.getScriptErrors(script);
Iterator<Expression> expressions = Iterators.filter(EcoreUtil2.eAll(script), Expression.class);
List<Diagnostic> result = Lists.<Diagnostic> newArrayList(Iterables.filter(diagnostics,
ExceptionDiagnostic.class));
while (expressions.hasNext()) {
Expression expression = expressions.next();
RuleEnvironment ruleEnvironment = RuleEnvironmentExtensions.newRuleEnvironment(expression);
Result<TypeRef> type = typeSystem.type(ruleEnvironment, expression);
if (type.getRuleFailedException() != null) {
Throwable cause = Throwables.getRootCause(type.getRuleFailedException());
if (!(cause instanceof RuleFailedException)) {
if (cause instanceof Exception) {
result.add(new ExceptionDiagnostic((Exception) cause));
} else {
throw new RuntimeException(cause);
}
}
}
}
validator.validate(script.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
return result;
}
示例2: ThreadsIterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
public ThreadsIterator(final SabotContext dbContext, final OperatorContext context) {
this.dbContext = dbContext;
threadMXBean = ManagementFactory.getThreadMXBean();
final long[] ids = threadMXBean.getAllThreadIds();
final Iterator<Long> threadIdIterator = Longs.asList(ids).iterator();
this.threadInfoIterator = Iterators.filter(
Iterators.transform(threadIdIterator, new Function<Long, ThreadInfo>() {
@Override
public ThreadInfo apply(Long input) {
return threadMXBean.getThreadInfo(input, 100);
}
}),
Predicates.notNull());
logger.debug("number of threads = {}, number of cores = {}", ids.length, NUMBER_OF_CORES);
this.stats = dbContext.getWorkStatsProvider().get();
}
示例3: getAllExpressions
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Iterator<Expression> getAllExpressions() {
final Predicate<EObject> _function = new Predicate<EObject>() {
public boolean apply(final EObject it) {
return (!(it instanceof FunctionDefinition));
}
};
return Iterators.<Expression>filter(EcoreUtilN4.getAllContentsFiltered(this, _function), Expression.class);
}
示例4: getAllStatements
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Iterator<Statement> getAllStatements() {
final Predicate<EObject> _function = new Predicate<EObject>() {
public boolean apply(final EObject it) {
return (!((it instanceof Expression) || (it instanceof FunctionDefinition)));
}
};
return Iterators.<Statement>filter(EcoreUtilN4.getAllContentsFiltered(this, _function), Statement.class);
}
示例5: getAllContentsFiltered
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
/**
* Returns all content filtered by given predicate. Children of filtered elements are omitted as well. Filtered
* means that the element does not satisfy the predicate. The given object itself is neither added to the result nor
* is it tested against the predicate.
*
* @param eobj
* the root object, may be null
* @return the tree iterator, may be an empty iterator but never null
*/
public static TreeIterator<EObject> getAllContentsFiltered(EObject eobj, final Predicate<EObject> predicate) {
if (eobj == null) {
return emptyTreeIterator();
}
return new AbstractTreeIterator<EObject>(eobj, false) {
private static final long serialVersionUID = 1L;
@Override
public Iterator<EObject> getChildren(Object element) {
return Iterators.filter(((EObject) element).eContents().iterator(), predicate);
}
};
}
示例6: getAllDirectlyFoundContentsOfType
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
/**
* Returns all content of a given type, ignoring all elements which are not of the given type. This filters out also
* elements of the given type, if their container has a different type. The given object itself is neither added to
* the result nor is it tested against the predicate.
*
* @param eobj
* the root object, may be null
* @return the tree iterator, may be an empty iterator but never null
*/
@SuppressWarnings("unchecked")
public static <T> TreeIterator<T> getAllDirectlyFoundContentsOfType(EObject eobj, final Class<T> type) {
if (eobj == null) {
return emptyTreeIterator();
}
return (TreeIterator<T>) new AbstractTreeIterator<EObject>(eobj, false) {
private static final long serialVersionUID = 1L;
@Override
public Iterator<? extends EObject> getChildren(Object element) {
return (Iterator<? extends EObject>) Iterators.filter(((EObject) element).eContents().iterator(), type);
}
};
}
示例7: iterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
public Iterator<T> iterator()
{
return Iterators.filter(this.objectList.iterator(), Predicates.notNull());
}
示例8: iterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
public Iterator iterator()
{
return Iterators.filter(this.objectList.iterator(), Predicates.notNull());
}
示例9: iterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
public Iterator<K> iterator()
{
return Iterators.filter(Iterators.forArray(this.byId), Predicates.notNull());
}
示例10: test
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Test
public void test() {
FileMynlpResource f = new FileMynlpResource(
new File("/Users/jimichan/project-new/mynlp/mynlp-segment/src/main/resources/maya_data/dictionary/core/CoreNatureDictionary.ngram.txt.zip"));
Iterator<String> x = Iterators.filter(f.openLineReader(), line -> line.startsWith("陈"));
Iterators.limit(x, 100).forEachRemaining(
line -> System.out.println(line)
);
}
示例11: getAllYieldExpressions
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Iterator<YieldExpression> getAllYieldExpressions() {
return Iterators.<YieldExpression>filter(this.getAllExpressions(), YieldExpression.class);
}
示例12: getAllReturnStatements
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Iterator<ReturnStatement> getAllReturnStatements() {
return Iterators.<ReturnStatement>filter(this.getAllStatements(), ReturnStatement.class);
}