@Override public boolean isEmpty() { return Collections.disjoint(set1, set2); }
private static boolean intersect(Set<?> a, Set<?> b) { return !disjoint(a, b); }
@Override public boolean isEmpty() { return Collections.disjoint(set1, set2); }
/** * Returns true if there is at least element that is in both s1 and s2. Faster * than calling intersection(Set,Set) if you don't need the contents of the * intersection. */ public static <E> boolean intersects(Set<E> s1, Set<E> s2) { // *ahem* It would seem that Java already had this method. Hopefully this // stub will help people find it better than I did. return !Collections.disjoint(s1, s2); }
@Override public boolean isEmpty() { return Collections.disjoint(set1, set2); }
private boolean hasTypeUseOrTypeParameter(Target targetAnnotation) { // Should only be in cases where Target is not in the classpath return targetAnnotation != null && !Collections.disjoint(FORBIDDEN_ELEMENT_TYPES, Arrays.asList(targetAnnotation.value())); }
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); } }
@Override public boolean equals(Object other) { if (this == other) { return true; } else if (!(other instanceof Key)) { return false; } Key key = (Key) other; return internalName.equals(key.internalName) && parameterCount == key.parameterCount && !Collections.disjoint(getIdentifiers(), key.getIdentifiers()); }
private static Graph getDisjointnessGraph(Map<String, Set<Block>> fields) { Graph graph = new Graph(fields.keySet().toArray(new String[0])); fields.forEach((name0, blockSet0) -> fields.forEach((name1, blockSet1) -> { if (name0.compareTo(name1) < 0 && Collections.disjoint(blockSet0, blockSet1)) { graph.addEdge(name0, name1); } }) ); return graph; }
private boolean doTypesOverlap(GraphQLType type, GraphQLCompositeType parent) { if (type == parent) { return true; } List<? extends GraphQLType> possibleParentTypes = getPossibleType(parent); List<? extends GraphQLType> possibleConditionTypes = getPossibleType(type); return !Collections.disjoint(possibleParentTypes, possibleConditionTypes); }
/** * Returns true if the given tree is annotated with a {@code @SuppressWarnings} that disables this * bug checker. */ public boolean isSuppressed(Tree tree) { SuppressWarnings suppression = ASTHelpers.getAnnotation(tree, SuppressWarnings.class); return suppression != null && !Collections.disjoint(Arrays.asList(suppression.value()), allNames()); }
/** * Returns true if the given symbol is annotated with a {@code @SuppressWarnings} that disables * this bug checker. */ public boolean isSuppressed(Symbol symbol) { SuppressWarnings suppression = ASTHelpers.getAnnotation(symbol, SuppressWarnings.class); return suppression != null && !Collections.disjoint(Arrays.asList(suppression.value()), allNames()); }
Set<Feature<?>> allAbsentFeatures = addImpliedFeatures(Helpers.<Feature<?>>copyToSet(absentFeatures)); if (!Collections.disjoint(allPresentFeatures, allAbsentFeatures)) { throw new ConflictingRequirementsException( "Annotation explicitly or "
/** 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()); }
TestSuite computeMultimapAsMapGetTestSuite( FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<M, Entry<K, V>>> parentBuilder) { Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures()); if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) { return new TestSuite(); } else { return CollectionTestSuiteBuilder.using( new MultimapAsMapGetGenerator<K, V, M>(parentBuilder.getSubjectGenerator())) .withFeatures(features) .named(parentBuilder.getName() + ".asMap[].get[key]") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite(); } }
@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(); } }
@Override TestSuite computeMultimapAsMapGetTestSuite( FeatureSpecificTestSuiteBuilder< ?, ? extends OneSizeTestContainerGenerator<ListMultimap<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 ListTestSuiteBuilder.using( new MultimapAsMapGetGenerator<K, V>(parentBuilder.getSubjectGenerator())) .withFeatures(features) .named(parentBuilder.getName() + ".asMap[].get[key]") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite(); } }
@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(); } } }
@Override public void onMetadataUpdate(Cluster cluster, Set<String> unavailableTopics) { // if we encounter any unauthorized topics, raise an exception to the user if (!cluster.unauthorizedTopics().isEmpty()) throw new TopicAuthorizationException(new HashSet<>(cluster.unauthorizedTopics())); // if we encounter any invalid topics, raise an exception to the user if (!cluster.invalidTopics().isEmpty()) throw new InvalidTopicException(cluster.invalidTopics()); if (subscriptions.hasPatternSubscription()) updatePatternSubscription(cluster); // check if there are any changes to the metadata which should trigger a rebalance if (subscriptions.partitionsAutoAssigned()) { MetadataSnapshot snapshot = new MetadataSnapshot(subscriptions, cluster); if (!snapshot.equals(metadataSnapshot)) metadataSnapshot = snapshot; } if (!Collections.disjoint(metadata.topics(), unavailableTopics)) metadata.requestUpdate(); } });
@After public void validateSourceAndTarget() { for (Integer node : network.nodes()) { for (String inEdge : network.inEdges(node)) { EndpointPair<Integer> endpointPair = network.incidentNodes(inEdge); assertThat(endpointPair.source()).isEqualTo(endpointPair.adjacentNode(node)); assertThat(endpointPair.target()).isEqualTo(node); } for (String outEdge : network.outEdges(node)) { EndpointPair<Integer> endpointPair = network.incidentNodes(outEdge); assertThat(endpointPair.source()).isEqualTo(node); assertThat(endpointPair.target()).isEqualTo(endpointPair.adjacentNode(node)); } for (Integer adjacentNode : network.adjacentNodes(node)) { Set<String> edges = network.edgesConnecting(node, adjacentNode); Set<String> antiParallelEdges = network.edgesConnecting(adjacentNode, node); assertThat(node.equals(adjacentNode) || Collections.disjoint(edges, antiParallelEdges)) .isTrue(); } } }