當前位置: 首頁>>代碼示例>>Java>>正文


Java CollectionUtils.intersection方法代碼示例

本文整理匯總了Java中org.apache.commons.collections4.CollectionUtils.intersection方法的典型用法代碼示例。如果您正苦於以下問題:Java CollectionUtils.intersection方法的具體用法?Java CollectionUtils.intersection怎麽用?Java CollectionUtils.intersection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.collections4.CollectionUtils的用法示例。


在下文中一共展示了CollectionUtils.intersection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addComposited

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
/**
 * Add an additional Map to the composite.
 *
 * @param map  the Map to be added to the composite
 * @throws IllegalArgumentException if there is a key collision and there is no
 *         MapMutator set to handle it.
 */
@SuppressWarnings("unchecked")
public synchronized void addComposited(final Map<K, V> map) throws IllegalArgumentException {
    for (int i = composite.length - 1; i >= 0; --i) {
        final Collection<K> intersect = CollectionUtils.intersection(this.composite[i].keySet(), map.keySet());
        if (intersect.size() != 0) {
            if (this.mutator == null) {
                throw new IllegalArgumentException("Key collision adding Map to CompositeMap");
            }
            this.mutator.resolveCollision(this, this.composite[i], map, intersect);
        }
    }
    final Map<K, V>[] temp = new Map[this.composite.length + 1];
    System.arraycopy(this.composite, 0, temp, 0, this.composite.length);
    temp[temp.length - 1] = map;
    this.composite = temp;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:24,代碼來源:CompositeMap.java

示例2: addComposited

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
/**
 * Add a Set to this composite.
 *
 * @param set  the set to add
 * @throws IllegalArgumentException if a SetMutator is set, but fails to resolve a collision
 * @throws UnsupportedOperationException if there is no SetMutator set
 * @throws NullPointerException if {@code set} is null
 * @see SetMutator
 */
public synchronized void addComposited(final Set<E> set) {
    for (final Set<E> existingSet : getSets()) {
        final Collection<E> intersects = CollectionUtils.intersection(existingSet, set);
        if (intersects.size() > 0) {
            if (this.mutator == null) {
                throw new UnsupportedOperationException(
                    "Collision adding composited set with no SetMutator set");
            }
            getMutator().resolveCollision(this, existingSet, set, intersects);
            if (CollectionUtils.intersection(existingSet, set).size() > 0) {
                throw new IllegalArgumentException(
                    "Attempt to add illegal entry unresolved by SetMutator.resolveCollision()");
            }
        }
    }
    all.add(set);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:27,代碼來源:CompositeSet.java

示例3: getIssues

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
/**
 * Return existing issues identifier for the given project. Min and max bounds are there to reduce the amount of
 * issues to get with this query.
 * 
 * @param dataSource
 *            The data source of JIRA database.
 * @param jira
 *            the JIRA project identifier.
 * @param minIssue
 *            the minimal issue number.
 * @param maxIssue
 *            the maximal issue number.
 * @param importIssues
 *            the issues to import (INSERT or UPDATE ?).
 * @return existing labels for the given project.
 */
public Map<Integer, IssueWithCollections> getIssues(final DataSource dataSource, final int jira, final int minIssue, final int maxIssue,
		final Set<Integer> importIssues) {
	final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
	final Set<Integer> existing = new HashSet<>(jdbcTemplate.queryForList(
			"SELECT issuenum FROM jiraissue WHERE PROJECT = ? AND issuenum >= ? AND issuenum <= ?", Integer.class, jira, minIssue, maxIssue));
	final Collection<Integer> updatingIssues = CollectionUtils.intersection(existing, importIssues);
	final Map<Integer, IssueWithCollections> result = new LinkedHashMap<>();
	if (!updatingIssues.isEmpty()) {
		final RowMapper<IssueWithCollections> rowMapper = new BeanPropertyRowMapper<>(IssueWithCollections.class);
		final List<IssueWithCollections> issues = jdbcTemplate.query("SELECT i.ID AS id, i.issuenum AS issue"
				+ " FROM jiraissue AS i WHERE i.PROJECT = ? AND i.issuenum IN (" + newIn(updatingIssues) + ") ORDER BY i.issuenum", rowMapper,
				ArrayUtils.addAll(new Object[] { jira }, updatingIssues.toArray()));
		for (final IssueWithCollections issue : issues) {
			result.put(issue.getId(), issue);
		}
	}
	return result;
}
 
開發者ID:ligoj,項目名稱:plugin-bt-jira,代碼行數:35,代碼來源:JiraDao.java


注:本文中的org.apache.commons.collections4.CollectionUtils.intersection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。