当前位置: 首页>>代码示例>>Java>>正文


Java Iterators.filter方法代码示例

本文整理汇总了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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:ExceptionAnalyser.java

示例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();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:ThreadsIterator.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:BlockImpl.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:BlockImpl.java

示例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);
		}
	};
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:EcoreUtilN4.java

示例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);
		}
	};
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:EcoreUtilN4.java

示例7: iterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
public Iterator<T> iterator()
{
    return Iterators.filter(this.objectList.iterator(), Predicates.notNull());
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:5,代码来源:ObjectIntIdentityMap.java

示例8: iterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
public Iterator iterator()
{
    return Iterators.filter(this.objectList.iterator(), Predicates.notNull());
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:5,代码来源:ObjectIntIdentityMap.java

示例9: iterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
public Iterator<K> iterator()
{
    return Iterators.filter(Iterators.forArray(this.byId), Predicates.notNull());
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:5,代码来源:IntIdentityHashBiMap.java

示例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)
    );


}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:16,代码来源:FileLineBasedResourceTest.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:BlockImpl.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:BlockImpl.java


注:本文中的com.google.common.collect.Iterators.filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。