Java Code Examples for java.util.Collections.disjoint()

The following are Jave code examples for showing how to use disjoint() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Lagerta   File: LeadPlanner.java   View Source Code Vote up 6 votes
private boolean isTxAvailableToCommitOnOwnNode(TxInfo txInfo, Lazy<UUID, Set<Object>> availableTxsPerNode) {
    Set<Object> sameNodeScope = availableTxsPerNode.get(txInfo.consumerId());

    if (sameNodeScope.containsAll(txInfo.scope())) {
        return true;
    }
    for (Map.Entry<UUID, Set<Object>> entry : availableTxsPerNode) {
        UUID nodeId = entry.getKey();
        Set<Object> nodeScope = entry.getValue();

        if (!nodeId.equals(txInfo.consumerId()) && !Collections.disjoint(nodeScope, txInfo.scope())) {
            return false;
        }
    }
    return true;
}
 
Example 2
Project: rapidminer   File: ProgressThread.java   View Source Code Vote up 6 votes
/**
 * Removes all queued threads that depend on the progress threads with the provided IDs. Also
 * all thread that depend on the threads that have been removed are removed recursively.
 * <p>
 * <strong>ATTENTION: Make sure this is only called from inside a synchronized block!</strong>
 * </p>
 * 
 * @param ids
 *            the progress thread IDs the queued progress threads should be checked for
 */
private static final void removeQueuedThreadsWithDependency(String... ids) {
	Iterator<ProgressThread> iterator = queuedThreads.iterator();

	// iterator over queued threads and remove the remove the ones that depend on one of the
	// provided IDs
	Set<String> cancelledThreads = new HashSet<>();
	while (iterator.hasNext()) {
		ProgressThread pg = iterator.next();
		if (!Collections.disjoint(Arrays.asList(ids), pg.getDependencies())) {
			iterator.remove();
			cancelledThreads.add(pg.getID());
		}
	}

	// also remove all the ones depending on the ones that have been cancelled.
	if (!cancelledThreads.isEmpty()) {
		removeQueuedThreadsWithDependency(cancelledThreads.toArray(new String[cancelledThreads.size()]));
	}
}
 
Example 3
Project: OperatieBRP   File: AdmhndProducerVoorLeveringServiceImpl.java   View Source Code Vote up 6 votes
private Set<HandelingVoorPublicatie> filterHandelingen(final Set<Long> personenInLevering, final SetMultimap<Long, Long> admhndMap) {
    final Set<HandelingVoorPublicatie> teLeverenHandelingen = new HashSet<>();
    //loop over handelingen zonder status in levering en bepaal unieke bijgehouden persoon sets
    for (Long admhnId : admhndMap.keySet()) {
        final Set<Long> bijgehoudenPersonen = admhndMap.get(admhnId);
        if (Collections.disjoint(bijgehoudenPersonen, personenInLevering)) {
            final HandelingVoorPublicatie handelingVoorPublicatie = new HandelingVoorPublicatie();
            handelingVoorPublicatie.setAdmhndId(admhnId);
            handelingVoorPublicatie.setBijgehoudenPersonen(bijgehoudenPersonen);
            teLeverenHandelingen.add(handelingVoorPublicatie);
            personenInLevering.addAll(bijgehoudenPersonen);
        } else {
            LOGGER.debug(String.format("admhnd %s voor persoon al in levering, discard voor nu. Worden later opgepakt", admhnId));
        }
    }
    return teLeverenHandelingen;
}
 
Example 4
Project: guava-mock   File: FeatureUtil.java   View Source Code Vote up 6 votes
/**
 * Find all the constraints explicitly or implicitly specified by a single
 * tester annotation.
 * @param testerAnnotation a tester annotation
 * @return the requirements specified by the annotation
 * @throws ConflictingRequirementsException if the requirements are mutually
 *         inconsistent.
 */
private static TesterRequirements buildTesterRequirements(Annotation testerAnnotation)
    throws ConflictingRequirementsException {
  Class<? extends Annotation> annotationClass = testerAnnotation.annotationType();
  final Feature<?>[] presentFeatures;
  final Feature<?>[] absentFeatures;
  try {
    presentFeatures = (Feature[]) annotationClass.getMethod("value").invoke(testerAnnotation);
    absentFeatures = (Feature[]) annotationClass.getMethod("absent").invoke(testerAnnotation);
  } catch (Exception e) {
    throw new IllegalArgumentException("Error extracting features from tester annotation.", e);
  }
  Set<Feature<?>> allPresentFeatures =
      addImpliedFeatures(Helpers.<Feature<?>>copyToSet(presentFeatures));
  Set<Feature<?>> allAbsentFeatures =
      addImpliedFeatures(Helpers.<Feature<?>>copyToSet(absentFeatures));
  if (!Collections.disjoint(allPresentFeatures, allAbsentFeatures)) {
    throw new ConflictingRequirementsException(
        "Annotation explicitly or "
            + "implicitly requires one or more features to be both present "
            + "and absent.",
        intersection(allPresentFeatures, allAbsentFeatures),
        testerAnnotation);
  }
  return new TesterRequirements(allPresentFeatures, allAbsentFeatures);
}
 
Example 5
Project: guava-mock   File: FeatureUtil.java   View Source Code Vote up 6 votes
private static void checkConflict(
    String earlierRequirement,
    Set<Feature<?>> earlierFeatures,
    String newRequirement,
    Set<Feature<?>> newFeatures,
    Object source)
    throws ConflictingRequirementsException {
  if (!Collections.disjoint(newFeatures, earlierFeatures)) {
    throw new ConflictingRequirementsException(
        String.format(
            Locale.ROOT,
            "Annotation requires to be %s features that earlier "
                + "annotations required to be %s.",
            newRequirement,
            earlierRequirement),
        intersection(newFeatures, earlierFeatures),
        source);
  }
}
 
Example 6
Project: guava-mock   File: SetMultimapTestSuiteBuilder.java   View Source Code Vote up 6 votes
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
  if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
    return new TestSuite();
  } else {
    return SetTestSuiteBuilder.using(
            new MultimapAsMapGetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
 
Example 7
Project: guava-mock   File: SortedSetMultimapTestSuiteBuilder.java   View Source Code Vote up 6 votes
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
  if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
    return new TestSuite();
  } else {
    return SortedSetTestSuiteBuilder.using(
            new SetMultimapTestSuiteBuilder.MultimapAsMapGetGenerator<K, V>(
                parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
 
Example 8
Project: openjdk-jdk10   File: Infer.java   View Source Code Vote up 6 votes
/**
 * Pick the leaf that minimize cost
 */
@Override
public Node pickNode(final InferenceGraph g) {
    treeCache.clear(); //graph changes at every step - cache must be cleared
    Pair<List<Node>, Integer> bestPath = noPath;
    for (Node n : g.nodes) {
        if (!Collections.disjoint(n.data, varsToSolve)) {
            Pair<List<Node>, Integer> path = computeTreeToLeafs(n);
            //discard all paths containing at least a node in the
            //closure computed above
            if (path.snd < bestPath.snd) {
                bestPath = path;
            }
        }
    }
    if (bestPath == noPath) {
        //no path leads there
        throw new NodeNotFoundException(g);
    }
    return bestPath.fst.head;
}
 
Example 9
Project: export-distro   File: ValueDescriptorSplitter.java   View Source Code Vote up 5 votes
private boolean hasMatching(Event event, List<String> vdIdentifiers) {
	try {
		return !Collections.disjoint(vdIdentifiers,
				event.getReadings().stream().map(r -> r.getName()).collect(Collectors.toList()));
	} catch (Exception e) {
		logger.error(
				"Problem getting event readings or associated value descriptor and checking against registration filters:  "
						+ e.getMessage());
		return false;
	}
}
 
Example 10
Project: Equella   File: BookmarkContextHolder.java   View Source Code Vote up 5 votes
public boolean matches(BookmarkContextHolder contextHolder)
{
	Set<String> allContexts = contextHolder.getContexts();
	if( !ignoreForContext.isEmpty() && !Collections.disjoint(ignoreForContext, allContexts) )
	{
		return false;
	}

	if( !onlyForContext.isEmpty() && Collections.disjoint(allContexts, onlyForContext) )
	{
		return false;
	}

	Set<String> ifc = contextHolder.getIgnoreForContext();
	if( !contexts.isEmpty() && !ifc.isEmpty() && !Collections.disjoint(contexts, ifc) )
	{
		return false;
	}

	Set<String> ofc = contextHolder.getOnlyForContext();
	if( !ofc.isEmpty() && Collections.disjoint(ofc, contexts) )
	{
		return false;
	}

	return true;
}
 
Example 11
Project: Matcher   File: ProjectConfig.java   View Source Code Vote up 5 votes
public boolean isValid() {
	return !pathsA.isEmpty()
			&& !pathsB.isEmpty()
			&& Collections.disjoint(pathsA, pathsB)
			&& Collections.disjoint(pathsA, sharedClassPath)
			&& Collections.disjoint(pathsB, sharedClassPath)
			&& Collections.disjoint(classPathA, classPathB)
			&& Collections.disjoint(classPathA, pathsA)
			&& Collections.disjoint(classPathB, pathsA)
			&& Collections.disjoint(classPathA, pathsB)
			&& Collections.disjoint(classPathB, pathsB)
			&& Collections.disjoint(classPathA, sharedClassPath)
			&& Collections.disjoint(classPathB, sharedClassPath);
}
 
Example 12
Project: SE2017-Team1   File: PetriNet.java   View Source Code Vote up 5 votes
private void checkIds(ArrayList<Integer> listOfIdsToBeAdded) throws petriNetException {
  	ArrayList<Integer> listOfIds = new ArrayList<Integer>();
  	for (Transition transition : transitions) {
  		listOfIds.add(transition.getId());
  	}
  	for (Place place : places) {
  		listOfIds.add(place.getId());
  	}
  	if (!Collections.disjoint(listOfIdsToBeAdded, listOfIds)) {
	throw new petriNetException(petriNetConstants.DUPLICATED);
}
  }
 
Example 13
Project: lams   File: TypeSafeActivator.java   View Source Code Vote up 5 votes
private static boolean applyConstraints(
		Set<ConstraintDescriptor<?>> constraintDescriptors,
		Property property,
		PropertyDescriptor propertyDesc,
		Set<Class<?>> groups,
		boolean canApplyNotNull,
		Dialect dialect) {
	boolean hasNotNull = false;
	for ( ConstraintDescriptor<?> descriptor : constraintDescriptors ) {
		if ( groups != null && Collections.disjoint( descriptor.getGroups(), groups ) ) {
			continue;
		}

		if ( canApplyNotNull ) {
			hasNotNull = hasNotNull || applyNotNull( property, descriptor );
		}

		// apply bean validation specific constraints
		applyDigits( property, descriptor );
		applySize( property, descriptor, propertyDesc );
		applyMin( property, descriptor, dialect );
		applyMax( property, descriptor, dialect );

		// apply hibernate validator specific constraints - we cannot import any HV specific classes though!
		// no need to check explicitly for @Range. @Range is a composed constraint using @Min and @Max which
		// will be taken care later
		applyLength( property, descriptor, propertyDesc );

		// pass an empty set as composing constraints inherit the main constraint and thus are matching already
		hasNotNull = hasNotNull || applyConstraints(
				descriptor.getComposingConstraints(),
				property, propertyDesc, null,
				canApplyNotNull,
                   dialect
		);
	}
	return hasNotNull;
}
 
Example 14
Project: Reer   File: JarClasspathSnapshot.java   View Source Code Vote up 4 votes
public boolean isAnyClassDuplicated(Set<String> classNames) {
    boolean noCommonElements = Collections.disjoint(data.getDuplicateClasses(), classNames);
    return !noCommonElements;
}
 
Example 15
Project: shibboleth-idp-oidc-extension   File: AttributeInOIDCRequestedClaimsMatcher.java   View Source Code Vote up 4 votes
@Override
public Set<IdPAttributeValue<?>> getMatchingValues(@Nonnull IdPAttribute attribute,
        @Nonnull AttributeFilterContext filtercontext) {
    ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
    List<String> names = resolveClaimNames(attribute.getEncoders());
    if (names.isEmpty()) {
        // This is always a failure.
        log.debug("{} No oidc encoders attached to attribute", getLogPrefix());
        return null;
    }
    OIDCAuthenticationResponseContext respCtx = getOIDCAuthenticationResponseContext(
            getOutboundMessageContext(filtercontext));
    if (respCtx == null) {
        // This is always a failure.
        log.debug("{} No oidc response ctx for this comparison", getLogPrefix());
        return null;
    }
    ClaimsRequest request = respCtx.getRequestedClaims();
    if (request == null || (request.getIDTokenClaims() == null && request.getUserInfoClaims() == null)) {
        log.debug("{} No claims in request", getLogPrefix());
        if (getMatchIRequestedClaimsSilent()) {
            log.debug("{} all values matched as in silent mode", getLogPrefix());
            return ImmutableSet.copyOf(attribute.getValues());
        } else {
            log.debug("{} none of the values matched as not silent mode", getLogPrefix());
            return null;
        }
    }
    if (request.getIDTokenClaimNames(false) != null && !getMatchOnlyUserInfo()) {
        if (!Collections.disjoint(request.getIDTokenClaimNames(false), names)) {
            log.debug("{} all values matched as {} is requested id token claims", getLogPrefix(),
                    attribute.getId());
            log.warn("{} Essential checking not implemented yet", getLogPrefix());
            // TODO: value based filtering with option onlyEssential
            return ImmutableSet.copyOf(attribute.getValues());
        }
    }
    if (request.getUserInfoClaimNames(false) != null && !getMatchOnlyIDToken()) {
        if (!Collections.disjoint(request.getUserInfoClaimNames(false), names)) {
            log.debug("{} all values matched as {} is requested user info claims", getLogPrefix(),
                    attribute.getId());
            log.warn("{} Essential checking not implemented yet", getLogPrefix());
            // TODO: value based filtering with option onlyEssential
            return ImmutableSet.copyOf(attribute.getValues());
        }
    }
    log.debug("{} attribute {} was not a requested claim, none of the values matched", getLogPrefix(),
            attribute.getId());
    return null;
}
 
Example 16
Project: Equella   File: HibernateMigrationHelper.java   View Source Code Vote up 4 votes
@SuppressWarnings({"unchecked"})
public List<String> getAddIndexesAndConstraintsForColumns(String tableName, boolean includeForeignKeyConstraints,
	String... columnNames)
{
	Set<Column> colSet = new HashSet<Column>();
	for( String columnName : columnNames )
	{
		colSet.add(new Column(columnName));
	}
	List<String> sqlStrings = new ArrayList<String>();

	Table table = findTable(tableName);
	if( !extDialect.supportsModifyWithConstraints() )
	{
		for( Column col : colSet )
		{
			Column realCol = table.getColumn(col);
			if( realCol.isUnique() )
			{
				table.createUniqueKey(Collections.singletonList(realCol));
			}
		}
	}
	Iterator<UniqueKey> keyIter = table.getUniqueKeyIterator();
	if( dialect.supportsUniqueConstraintInCreateAlterTable() )
	{
		while( keyIter.hasNext() )
		{
			UniqueKey uk = keyIter.next();
			if( !Collections.disjoint(uk.getColumns(), colSet) )
			{
				StringBuilder buf = new StringBuilder("alter table ");
				buf.append(table.getQualifiedName(dialect, defaultCatalog, defaultSchema));
				buf.append(" add constraint ");
				buf.append(extDialect.getRandomIdentifier());
				buf.append(' ');
				String constraint = uk.sqlConstraintString(dialect);
				if( constraint != null )
				{
					buf.append(constraint);
					sqlStrings.add(buf.toString());
				}
			}
		}
	}
	else
	{
		while( keyIter.hasNext() )
		{
			UniqueKey ukey = keyIter.next();
			if( !Collections.disjoint(ukey.getColumns(), colSet) )
			{
				sqlStrings.add(ukey.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
			}
		}
	}

	addIndexSQL(sqlStrings, table, colSet);

	// Caller may opt to skip foreign key constraints
	if( includeForeignKeyConstraints )
	{
		Iterator<ForeignKey> fkeyIter = table.getForeignKeyIterator();
		while( fkeyIter.hasNext() )
		{
			ForeignKey fkey = fkeyIter.next();
			if( !Collections.disjoint(fkey.getColumns(), colSet) )
			{
				sqlStrings.add(fkey.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
			}
		}
	}

	return sqlStrings;
}
 
Example 17
Project: Equella   File: WorkflowServiceImpl.java   View Source Code Vote up 4 votes
@Override
public boolean canCurrentUserModerate(PropBagEx itemxml, WorkflowItem task, WorkflowItemStatus status)
{
	UserState userState = CurrentUser.getUserState();
	if( userState.isSystem() )
	{
		return true;
	}
	String userID = CurrentUser.getUserID();
	Set<String> acceptedUsers = status.getAcceptedUsers();
	if( acceptedUsers.contains(userID) )
	{
		return false;
	}
	Set<String> groups = task.getGroups();
	if( !Check.isEmpty(groups) )
	{
		Set<String> currentGroups = CurrentUser.getUsersGroups();
		if( !Collections.disjoint(groups, currentGroups) )
		{
			return true;
		}
	}
	Set<String> users = task.getUsers();
	if( !Check.isEmpty(users) && users.contains(userID) )
	{
		return true;
	}

	String path = task.getUserPath();
	if( !Check.isEmpty(path) && itemxml.getNodeList(path).contains(userID) )
	{
		return true;
	}

	if( !Check.isEmpty(task.getRoles()) )
	{
		Set<String> roles = userState.getUsersRoles();
		if( !Collections.disjoint(roles, task.getRoles()) )
		{
			return true;
		}
	}

	return false;
}
 
Example 18
Project: spring-cloud-skipper   File: ShellUtils.java   View Source Code Vote up 2 votes
/**
 * Checks if given application arguments contains any usual help option.
 *
 * @param args the application arguments
 * @return true if arguments contain common help option
 */
public static boolean hasHelpOption(ApplicationArguments args) {
	return !Collections.disjoint(helpArgs, args.getNonOptionArgs()) || !Collections.disjoint(helpArgs, args.getOptionNames());
}
 
Example 19
Project: xmlrss   File: PSSignatureOutput.java   View Source Code Vote up 2 votes
/**
 * Checks if the given collection and the values of this <code>SignedSet</code> are disjoint.
 *
 * @param c collection that is checked to be disjoint
 * @return true if all elements of <code>c</code> are not values of this set.
 */
public boolean isDisjoint(Collection<ByteArray> c) {
    return Collections.disjoint(c, values());
}
 
Example 20
Project: OperatieBRP   File: Partij.java   View Source Code Vote up 2 votes
/**
 * Geeft true als deze partij de rol van bijhouder heeft, anders false.
 * @return true voor bijhouder, anders false
 */
public final boolean isBijhouder() {
    return !Collections.disjoint(getRollen(), BIJHOUDER_ROLLEN);
}