本文整理了Java中org.apache.commons.collections.CollectionUtils.containsAny()
方法的一些代码示例,展示了CollectionUtils.containsAny()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CollectionUtils.containsAny()
方法的具体详情如下:
包路径:org.apache.commons.collections.CollectionUtils
类名称:CollectionUtils
方法名:containsAny
[英]Returns true
iff at least one element is in both collections.
In other words, this method returns true
iff the #intersection of coll1 and coll2 is not empty.
[中]如果两个集合中至少有一个元素,则返回true
。
换句话说,如果coll1和coll2的#交集不为空,此方法返回true
。
代码示例来源:origin: apache/kylin
private Pair<Boolean, Set<String>> hasOverlap(ArrayList<Set<String>> dimsList, Set<String> Dims) {
Set<String> existing = new HashSet<>();
Set<String> overlap = new HashSet<>();
for (Set<String> dims : dimsList) {
if (CollectionUtils.containsAny(existing, dims)) {
overlap.addAll(ensureOrder(CollectionUtils.intersection(existing, dims)));
}
existing.addAll(dims);
}
return new Pair<>(overlap.size() > 0, overlap);
}
代码示例来源:origin: commons-collections/commons-collections
CollectionUtils.containsAny(one,odds));
assertTrue("containsAny({1,3},{1}) should return true.",
CollectionUtils.containsAny(odds,one));
assertTrue("containsAny({3},{1,3}) should return true.",
CollectionUtils.containsAny(three,odds));
assertTrue("containsAny({1,3},{3}) should return true.",
CollectionUtils.containsAny(odds,three));
assertTrue("containsAny({2},{2}) should return true.",
CollectionUtils.containsAny(two,two));
assertTrue("containsAny({1,3},{1,3}) should return true.",
CollectionUtils.containsAny(odds,odds));
!CollectionUtils.containsAny(two,odds));
assertTrue("containsAny({1,3},{2}) should return false.",
!CollectionUtils.containsAny(odds,two));
assertTrue("containsAny({1},{3}) should return false.",
!CollectionUtils.containsAny(one,three));
assertTrue("containsAny({3},{1}) should return false.",
!CollectionUtils.containsAny(three,one));
assertTrue("containsAny({1,3},{}) should return false.",
!CollectionUtils.containsAny(odds,empty));
assertTrue("containsAny({},{1,3}) should return false.",
!CollectionUtils.containsAny(empty,odds));
assertTrue("containsAny({},{}) should return false.",
!CollectionUtils.containsAny(empty,empty));
代码示例来源:origin: apache/kylin
if (CollectionUtils.containsAny(mandatoryDims, hierarchyDims)) {
logger.warn("Aggregation group " + index + " mandatory dimensions overlap with hierarchy dimensions: "
+ ensureOrder(CollectionUtils.intersection(mandatoryDims, hierarchyDims)));
if (CollectionUtils.containsAny(mandatoryDims, jointDims)) {
logger.warn("Aggregation group " + index + " mandatory dimensions overlap with joint dimensions: "
+ ensureOrder(CollectionUtils.intersection(mandatoryDims, jointDims)));
if (CollectionUtils.containsAny(hierarchyDims, jointDims)) {
logger.error("Aggregation group " + index + " hierarchy dimensions overlap with joint dimensions");
throw new IllegalStateException(
代码示例来源:origin: apache/kylin
if (CollectionUtils.containsAny(mandatoryDims, hierarchyDims)) {
Set<String> intersection = new HashSet<>(mandatoryDims);
intersection.retainAll(hierarchyDims);
continue;
if (CollectionUtils.containsAny(mandatoryDims, jointDims)) {
Set<String> intersection = new HashSet<>(mandatoryDims);
intersection.retainAll(jointDims);
oneJoint.add(s);
if (CollectionUtils.containsAny(existing, oneJoint)) {
overlap.addAll(CollectionUtils.intersection(existing, oneJoint));
代码示例来源:origin: apache/ignite
assertFalse("List of shared memory IDs after server-client interactions should not include IDs created " +
"(on Linux): within client-server interactions.",
CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions));
if (CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions))
U.sleep(1000);
else
CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions));
代码示例来源:origin: apache/ignite
/**
* @throws Exception If failed.
*/
@Test
public void testClientThrowsCorrectExceptionUponServerKilling() throws Exception {
info("Shared memory IDs before starting server-client interactions: " +
IpcSharedMemoryUtils.sharedMemoryIds());
Collection<Integer> shmemIdsWithinInteractions = checkClientThrowsCorrectExceptionUponServerKilling();
Collection<Integer> shmemIdsAfterInteractions = IpcSharedMemoryUtils.sharedMemoryIds();
info("Shared memory IDs created within interaction: " + shmemIdsWithinInteractions);
info("Shared memory IDs after server killing and client graceful termination: " + shmemIdsAfterInteractions);
assertFalse("List of shared memory IDs after killing server endpoint should not include IDs created " +
"within server-client interactions.",
CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions));
}
代码示例来源:origin: apache/ignite
info("Shared memory IDs after killing client endpoint: " + shmemIdsAfterInteractions);
if (CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions))
U.sleep(1000);
else
CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions));
代码示例来源:origin: hugegraph/hugegraph
public List<Id> joinPath(Node back) {
// Get self path
List<Id> path = this.path();
// Get reversed other path
List<Id> backPath = back.path();
Collections.reverse(backPath);
// Avoid loop in path
if (CollectionUtils.containsAny(path, backPath)) {
return ImmutableList.of();
}
// Append other path behind self path
path.addAll(backPath);
return path;
}
代码示例来源:origin: OAuth-Apis/apis
/**
* Delete all scopes from clients that are not valid anymore with the new
* resource server
*
* @param newScopes the newly saved scopes
* @param oldScopes the scopes from the existing resource server
* @param clients the clients of the resource server
*/
@SuppressWarnings("unchecked")
protected void pruneClientScopes(final List<String> newScopes, List<String> oldScopes, Set<Client> clients) {
if (!newScopes.containsAll(oldScopes)) {
subtract(oldScopes, newScopes);
Collection<String> outdatedScopes = subtract(oldScopes, newScopes);
LOG.info("Resource server has updated scopes. Will remove all outdated scopes from clients: {}", outdatedScopes);
for (Client c : clients) {
final List<String> clientScopes = c.getScopes();
if (CollectionUtils.containsAny(clientScopes, outdatedScopes)) {
ArrayList<String> prunedScopes = new ArrayList<String>(subtract(clientScopes, outdatedScopes));
LOG.info("Client scopes of client {} were: {}. After pruning (because resourceServer has new scopes): {}",
new Object[]{c.getClientId(), c.getScopes(), prunedScopes});
c.setScopes(prunedScopes);
}
}
}
}
代码示例来源:origin: uk.gov.gchq.gaffer/graph
protected final boolean validateAuths(final Set<String> userAuths, final Set<String> validAuth, final boolean ifValidAuthIsNull) {
boolean rtn = ifValidAuthIsNull;
if (null != validAuth) {
if (null == userAuths) {
rtn = validAuth.isEmpty();
} else {
rtn = CollectionUtils.containsAny(userAuths, validAuth);
}
}
return rtn;
}
代码示例来源:origin: org.littleshoot/sip-stack
public boolean hasConnectionForAny(
final Collection<InetSocketAddress> socketAddresses)
{
synchronized (this.m_socketAddressesToIo)
{
final Collection<InetSocketAddress> existingAddresses =
this.m_socketAddressesToIo.keySet();
return CollectionUtils.containsAny(existingAddresses,
socketAddresses);
}
}
代码示例来源:origin: com.atlassian.confluence.plugins/confluence-masterdetail-plugin
private boolean hasDupeKeys(List<Map<String, PageProperty>> detailMapList, Map<String, PageProperty> details)
{
final Set<String> incomingKeys = details.keySet();
return detailMapList.stream().anyMatch(existingMap -> containsAny(existingMap.keySet(), incomingKeys));
}
代码示例来源:origin: com.atlassian.jira/jira-core
private boolean schemeContainsOptions(final FieldConfigScheme fieldConfigScheme, final Collection<Option> options)
{
final Set<Option> schemeOptions = new HashSet<Option>(jqlSelectOptionsUtil.getOptionsForScheme(fieldConfigScheme));
return CollectionUtils.containsAny(schemeOptions, options);
}
代码示例来源:origin: dhis2/dhis2-core
/**
* Indicates whether this user can manage the given user group.
*
* @param userGroup the user group to test.
* @return true if the given user group can be managed by this user, false if not.
*/
public boolean canManage( UserGroup userGroup )
{
return userGroup != null && CollectionUtils.containsAny( groups, userGroup.getManagedByGroups() );
}
代码示例来源:origin: com.atlassian.jira/jira-core
private boolean matchesOptionsPositive(final FieldConfigScheme fieldConfigScheme, final Set<Option> positiveOps, final Set<Option> negativeOps)
{
if (positiveOps.isEmpty())
{
return false;
}
final Set<Option> options = new HashSet<Option>(jqlSelectOptionsUtil.getOptionsForScheme(fieldConfigScheme));
//Note that if we can't match a parent, then we can't match any of its children.
removeOptions(options, negativeOps);
return CollectionUtils.containsAny(options, positiveOps);
}
代码示例来源:origin: org.apache.kylin/kylin-core-cube
private Pair<Boolean, Set<String>> hasOverlap(ArrayList<Set<String>> dimsList, Set<String> Dims) {
Set<String> existing = new HashSet<>();
Set<String> overlap = new HashSet<>();
for (Set<String> dims : dimsList) {
if (CollectionUtils.containsAny(existing, dims)) {
overlap.addAll(ensureOrder(CollectionUtils.intersection(existing, dims)));
}
existing.addAll(dims);
}
return new Pair<>(overlap.size() > 0, overlap);
}
代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl
@Override
public void enhanceMetadata(BxDocument document, YElement metadata, Set<EnhancedField> enhancedFields) {
Set<EnhancedField> fieldsToEnhance = getEnhancedFields();
if (! CollectionUtils.containsAny(enhancedFields, fieldsToEnhance)) {
if (enhanceMetadata(document, metadata)) {
enhancedFields.addAll(fieldsToEnhance);
}
}
}
}
代码示例来源:origin: pl.edu.icm.synat/synat-core-services-impl
private void verifyAddAgainstRemove() {
if (CollectionUtils.containsAny(mergedOperations.getTagsToAdd(), mergedOperations.getTagsToRemove())) {
throwException("some tag is in the same time added and removed ");
}
final Set<String> allNewPaths = mergedOperations.getPartsToAdd().keySet();
final Collection<String> allToRemovePaths = mergedOperations.getPartsToRemove();
if (CollectionUtils.containsAny(allNewPaths,
allToRemovePaths)) {
throwException("some parts are in the same time added and removed ");
}
}
代码示例来源:origin: org.nuiton.wikitty/wikitty-api
@Override
public void removeExtensions(Collection<String> ext) {
if (CollectionUtils.containsAny(target.getExtensionNames(), ext)) {
substituteTargetWithCopy();
target.removeExtensions(ext);
}
}
代码示例来源:origin: FenixEdu/fenixedu-academic
static private boolean hasStudentStatuteType(final SearchStudentsByDegreeParametersBean searchBean,
final Registration registration) {
return CollectionUtils.containsAny(searchBean.getStudentStatuteTypes(), registration.getStudent()
.getStatutesTypesValidOnAnyExecutionSemesterFor(searchBean.getExecutionYear()));
}
内容来源于网络,如有侵权,请联系作者删除!