本文整理匯總了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);
}