Java Code Examples for java.util.Collections#disjoint()
The following examples show how to use
java.util.Collections#disjoint() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: rapidminer-studio File: ProgressThread.java License: GNU Affero General Public License v3.0 | 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 2
Source Project: Akatsuki File: SourceTreeModel.java License: Apache License 2.0 | 6 votes |
private static boolean annotatedElementValid(ProcessorContext context, Element element) { // sanity check if (!element.getKind().equals(ElementKind.FIELD)) { context.messager().printMessage(Kind.ERROR, "annotated target must be a field", element); return false; } // more sanity check if (!(element instanceof VariableElement)) { context.messager().printMessage(Kind.ERROR, "Element is not a variable?! (should not happen at all) ", element); return false; } // check for invalid modifiers, we can only create classes in the // same package if (!Collections.disjoint(element.getModifiers(), DISALLOWED_MODIFIERS)) { context.messager().printMessage(Kind.ERROR, "field with " + DISALLOWED_MODIFIERS.toString() + " " + "cannot be retained", element); return false; } return true; }
Example 3
Source Project: lua-for-android File: Infer.java License: BSD 3-Clause "New" or "Revised" License | 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 4
Source Project: oodt File: MimeTypeCrawlerAction.java License: Apache License 2.0 | 6 votes |
@Override public boolean performAction(File product, Metadata productMetadata) throws CrawlerActionException { List<String> mimeTypeHierarchy = productMetadata .getAllMetadata(MIME_TYPES_HIERARCHY); if (mimeTypeHierarchy == null) { mimeTypeHierarchy = new Vector<String>(); } if (mimeTypes == null || (!Collections.disjoint(mimeTypes, mimeTypeHierarchy))) { return this.actionToCall.performAction(product, productMetadata); } else { LOG.log(Level.INFO, "Skipping action (id = " + this.getId() + " : description = " + this.getDescription() + " - doesn't apply to current product"); return true; } }
Example 5
Source Project: kafka-helmsman File: ConfigDrift.java License: MIT License | 5 votes |
/** * Check if there is a config drift between two topic configuration states. * * @param desired the desired {@link ConfiguredTopic} * @param actual an actual {@link ConfiguredTopic} * @param type the checking mode, see {@link Type} * @return a result indicating drift along with a sense of safety */ public Result check(ConfiguredTopic desired, ConfiguredTopic actual, Type type) { checkArgument(desired.getName().equals(actual.getName()), "Config drift check should only be applied to same topics!"); switch (type) { case ANY: return desired.equals(actual) ? Result.NO_DRIFT : Result.SAFETY_UNKNOWN_DRIFT; case PARTITION_COUNT: if (desired.getPartitions() == actual.getPartitions()) { return Result.NO_DRIFT; } else { if (desired.getPartitions() <= partitionCountLowWaterMark) { return Result.SAFE_DRIFT; } else if (desired.getPartitions() > partitionCountHighWaterMark) { return Result.UNSAFE_DRIFT; } float increase = (desired.getPartitions() - actual.getPartitions()) * 1.0f / actual.getPartitions(); return increase <= partitionIncreaseThreshold ? Result.SAFE_DRIFT : Result.UNSAFE_DRIFT; } case TOPIC_CONFIG: if (desired.getConfig().equals(actual.getConfig())) { return Result.NO_DRIFT; } else { if (Collections.disjoint(desired.getConfig().keySet(), unsafeConfigProperties)) { return Result.SAFE_DRIFT; } else { return Result.UNSAFE_DRIFT; } } default: throw new IllegalStateException("Unknown config drift!"); } }
Example 6
Source Project: calcite File: MaterializedViewRule.java License: Apache License 2.0 | 5 votes |
protected List<Set<RexTableInputRef>> getEquivalenceClasses() { if (cacheEquivalenceClasses == null) { Set<RexTableInputRef> visited = new HashSet<>(); ImmutableList.Builder<Set<RexTableInputRef>> builder = ImmutableList.builder(); for (Set<RexTableInputRef> set : nodeToEquivalenceClass.values()) { if (Collections.disjoint(visited, set)) { builder.add(set); visited.addAll(set); } } cacheEquivalenceClasses = builder.build(); } return cacheEquivalenceClasses; }
Example 7
Source Project: bgpcep File: MatchClusterIdSetHandler.java License: Eclipse Public License 1.0 | 5 votes |
private boolean matchClusterIdCondition( final ClusterIdentifier localClusterId, final ClusterId clusterId, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang .odl.bgp._default.policy.rev200120.match.cluster.id.set.condition.grouping .MatchClusterIdSetCondition matchClusterIdSetCondition) { final ClusterIdSet clusterIdSet = this.sets.getUnchecked(StringUtils .substringBetween(matchClusterIdSetCondition.getClusterIdSet(), "=\"", "\"")); if (clusterIdSet == null) { return false; } final MatchSetOptionsType matchOption = matchClusterIdSetCondition.getMatchSetOptions(); if (clusterId != null) { List<ClusterIdentifier> newList = new ArrayList<>(); if (clusterIdSet.getClusterId() != null) { newList.addAll(clusterIdSet.getClusterId()); } if (clusterIdSet.getLocal() != null) { newList.add(localClusterId); } final List<ClusterIdentifier> matchClusterList = clusterId.getCluster(); if (matchOption.equals(MatchSetOptionsType.ALL)) { return matchClusterList.containsAll(newList) && newList.containsAll(matchClusterList); } final boolean noneInCommon = Collections.disjoint(matchClusterList, newList); if (matchOption.equals(MatchSetOptionsType.ANY)) { return !noneInCommon; } else if (matchOption.equals(MatchSetOptionsType.INVERT)) { return noneInCommon; } } else if (matchOption.equals(MatchSetOptionsType.INVERT)) { return true; } return false; }
Example 8
Source Project: fenixedu-academic File: Over23IndividualCandidacyProcess.java License: GNU Lesser General Public License v3.0 | 5 votes |
static private boolean isAllowedToManageProcess(Over23IndividualCandidacyProcess process, User userView) { Set<AcademicProgram> programs = AcademicAccessRule.getProgramsAccessibleToFunction(AcademicOperationType.MANAGE_INDIVIDUAL_CANDIDACIES, userView.getPerson().getUser()).collect(Collectors.toSet()); if (process == null || process.getCandidacy() == null) { return false; } return !Collections.disjoint(programs, process.getCandidacy().getSelectedDegrees()); }
Example 9
Source Project: cxf File: JweJsonConsumer.java License: Apache License 2.0 | 5 votes |
protected final JweJsonEncryptionEntry getEncryptionObject(Map<String, Object> encryptionEntry) { Map<String, Object> header = CastUtils.cast((Map<?, ?>)encryptionEntry.get("header")); JweHeaders recipientUnprotected = header == null ? null : new JweHeaders(header); String encodedKey = (String)encryptionEntry.get("encrypted_key"); JweJsonEncryptionEntry entry = new JweJsonEncryptionEntry(recipientUnprotected, encodedKey); JweHeaders unionHeaders = new JweHeaders(); if (protectedHeaderJwe != null) { unionHeaders.asMap().putAll(protectedHeaderJwe.asMap()); unionHeaders.setProtectedHeaders(protectedHeaderJwe); } if (sharedUnprotectedHeader != null) { if (!Collections.disjoint(unionHeaders.asMap().keySet(), sharedUnprotectedHeader.asMap().keySet())) { LOG.warning("Protected and unprotected headers have duplicate values"); throw new JweException(JweException.Error.INVALID_JSON_JWE); } unionHeaders.asMap().putAll(sharedUnprotectedHeader.asMap()); } if (recipientUnprotected != null) { if (!Collections.disjoint(unionHeaders.asMap().keySet(), recipientUnprotected.asMap().keySet())) { LOG.warning("Union and recipient unprotected headers have duplicate values"); throw new JweException(JweException.Error.INVALID_JSON_JWE); } unionHeaders.asMap().putAll(recipientUnprotected.asMap()); } recipientsMap.put(entry, unionHeaders); return entry; }
Example 10
Source Project: sakai File: CalculatedQuestionExtractListener.java License: Educational Community License v2.0 | 5 votes |
/** * validateExtractedNames looks through all of the variable and formula names defined * in the instructions and determines if the names are valid, and if the formula and * variable names overlap. * @param item * @return a list of validation errors to display */ private List<String> validateExtractedNames(List<String> variableNames, List<String> formulaNames) { List<String> errors = new ArrayList<String>(); // formula validations for (String formula : formulaNames) { if (formula == null || formula.length() == 0) { errors.add(getErrorMessage("formula_name_empty")); } else { if (!formula.matches("[a-zA-Z]\\w*")) { errors.add(getErrorMessage("formula_name_invalid")); } } } // variable validations for (String variable : variableNames) { if (variable == null || variable.length() == 0) { errors.add(getErrorMessage("variable_name_empty")); } else { if (!variable.matches("[a-zA-Z]\\w*")) { errors.add(getErrorMessage("variable_name_invalid")); } } } // throw an error if variables and formulas share any names // don't continue processing if there are problems with the extract if (!Collections.disjoint(formulaNames, variableNames)) { errors.add(getErrorMessage("unique_names")); } return errors; }
Example 11
Source Project: tomee File: BValInterceptor.java License: Apache License 2.0 | 5 votes |
private static Collection<ExecutableType> removeFrom(Collection<ExecutableType> coll, ExecutableType... executableTypes) { Validate.notNull(coll, "collection was null"); if (!(coll.isEmpty() || ObjectUtils.isEmptyArray(executableTypes))) { final List<ExecutableType> toRemove = Arrays.asList(executableTypes); if (!Collections.disjoint(coll, toRemove)) { final Set<ExecutableType> result = EnumSet.copyOf(coll); result.removeAll(toRemove); return result; } } return coll; }
Example 12
Source Project: deadcode4j File: SuperClassAnalyzer.java License: Apache License 2.0 | 5 votes |
@Override protected final void analyzeClass(@Nonnull AnalysisContext analysisContext, @Nonnull CtClass clazz) { Set<String> knownSuperClasses = getSuperClassesFoundInClassPath(analysisContext); if (knownSuperClasses.isEmpty()) { return; } String clazzName = clazz.getName(); analysisContext.addAnalyzedClass(clazzName); if (!Collections.disjoint(knownSuperClasses, getClassHierarchy(clazz))) { analysisContext.addDependencies(this.dependerId, clazzName); } }
Example 13
Source Project: hbase File: HStore.java License: Apache License 2.0 | 5 votes |
/** Adds the files to compacting files. filesCompacting must be locked. */ private void addToCompactingFiles(Collection<HStoreFile> filesToAdd) { if (CollectionUtils.isEmpty(filesToAdd)) { return; } // Check that we do not try to compact the same StoreFile twice. if (!Collections.disjoint(filesCompacting, filesToAdd)) { Preconditions.checkArgument(false, "%s overlaps with %s", filesToAdd, filesCompacting); } filesCompacting.addAll(filesToAdd); Collections.sort(filesCompacting, storeEngine.getStoreFileManager().getStoreFileComparator()); }
Example 14
Source Project: addressbook-level1 File: AddressBook.java License: MIT License | 5 votes |
/** * Retrieves all persons in the full model whose names contain some of the specified keywords. * * @param keywords for searching * @return list of persons in full model with name containing some of the keywords */ private static ArrayList<String[]> getPersonsWithNameContainingAnyKeyword(Collection<String> keywords) { final ArrayList<String[]> matchedPersons = new ArrayList<>(); for (String[] person : getAllPersonsInAddressBook()) { final Set<String> wordsInName = new HashSet<>(splitByWhitespace(getNameFromPerson(person))); if (!Collections.disjoint(wordsInName, keywords)) { matchedPersons.add(person); } } return matchedPersons; }
Example 15
Source Project: gemfirexd-oss File: FixedPartitioningTest.java License: Apache License 2.0 | 4 votes |
/** * Validation method that verifies whether the partition num buckets for * partitions are satisfied. * * @param pr * Partitioned Region * @param fpas * List of FixedPartitionAttributes * @param partition2Buckets * Map of partition to buckets */ protected void verifyPartitionNumBuckets(PartitionedRegion pr, List<FixedPartitionAttributesImpl> fpas, Map<String, Set<Integer>> partition2Buckets) { for (FixedPartitionAttributes fpa : fpas) { String partitionName = fpa.getPartitionName(); Set<Integer> bucketIdsOnMemberForPR = new HashSet<Integer>(); // Verify that for each partition there are right number of buckets. if (partition2Buckets.get(partitionName) != null) { Set<Integer> bucketIdSetForPartition = (Set<Integer>)partition2Buckets .get(partitionName); int expectedNumBucketsForPartition = fpa.getNumBuckets(); if (bucketIdSetForPartition.size() != expectedNumBucketsForPartition) { throw new TestException("For the partitioned region " + pr.getName() + " for partition name " + partitionName + " expected number of buckets is " + expectedNumBucketsForPartition + " (" + fpa + ") but found " + bucketIdSetForPartition.size() + " bucket ids for this partition is " + bucketIdSetForPartition); } else { hydra.Log.getLogWriter().info( "For the partitioned region " + pr.getName() + " for partition name " + partitionName + " found the expected number of buckets " + expectedNumBucketsForPartition + " bucket ids are " + bucketIdSetForPartition); } // Verify that no two partitions share the same bucket if (!Collections.disjoint(bucketIdSetForPartition, bucketIdsOnMemberForPR)) { throw new TestException( "For the partitioned region " + pr.getName() + " for partition name " + partitionName + " bucket is shared with other partitions. Partition2Bucket map is " + partition2Buckets); } } hydra.Log.getLogWriter().info( "Partition to bucket map for the partitioned region " + pr.getName() + " is " + partition2Buckets); } }
Example 16
Source Project: trekarta File: IDNA.java License: GNU General Public License v3.0 | 4 votes |
/** * @internal * @deprecated This API is ICU internal only. */ @Deprecated protected static boolean hasCertainErrors(Info info, EnumSet<Error> errors) { return !info.errors.isEmpty() && !Collections.disjoint(info.errors, errors); }
Example 17
Source Project: BART File: GenerateStratification.java License: MIT License | 4 votes |
private boolean haveOverlap(Dependency d1, Dependency d2, Map<Dependency, Set<AttributeRef>> affectedAttributes, Map<Dependency, Set<AttributeRef>> queriedAttributes) { Set<AttributeRef> attributes1 = affectedAttributes.get(d1); Set<AttributeRef> attributes2 = queriedAttributes.get(d2); return !Collections.disjoint(attributes1, attributes2); }
Example 18
Source Project: trekarta File: IDNA.java License: GNU General Public License v3.0 | 4 votes |
/** * @internal * @deprecated This API is ICU internal only. */ @Deprecated protected static boolean hasCertainLabelErrors(Info info, EnumSet<Error> errors) { return !info.labelErrors.isEmpty() && !Collections.disjoint(info.labelErrors, errors); }
Example 19
Source Project: pushfish-android File: JarClasspathSnapshot.java License: BSD 2-Clause "Simplified" License | 4 votes |
public boolean isAnyClassDuplicated(Set<String> classNames) { boolean noCommonElements = Collections.disjoint(data.getDuplicateClasses(), classNames); return !noCommonElements; }
Example 20
Source Project: pitest File: JUnitCustomRunnerTestUnitFinder.java License: Apache License 2.0 | 4 votes |
private boolean isIncludedCategory(final Class<?> a) { final List<String> included = this.config.getIncludedGroups(); return included.isEmpty() || !Collections.disjoint(included, getCategories(a)); }