當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。