@Override public boolean containsAll(Collection<?> c) { return map.keySet().containsAll(c); }
/** An implementation for {@link Set#equals(Object)}. */ static boolean equalsImpl(Set<?> s, @Nullable Object object) { if (s == object) { return true; } if (object instanceof Set) { Set<?> o = (Set<?>) object; try { return s.size() == o.size() && s.containsAll(o); } catch (NullPointerException | ClassCastException ignored) { return false; } } return false; }
public void noMoreSplits(PlanNodeId planNodeId) { if (noMoreSplits.contains(planNodeId)) { return; } noMoreSplits.add(planNodeId); if (noMoreSplits.size() < sourceStartOrder.size()) { return; } checkState(noMoreSplits.size() == sourceStartOrder.size()); checkState(noMoreSplits.containsAll(sourceStartOrder)); status.setNoMoreLifespans(); }
private OAuth1aToken(Map<String, String> params) { // Map builder with default version value. final ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); for (Entry<String, String> param : params.entrySet()) { final String key = param.getKey(); final String value = param.getValue(); // Empty values are ignored. if (!Strings.isNullOrEmpty(value)) { final String lowerCased = Ascii.toLowerCase(key); if (DEFINED_PARAM_KEYS.contains(lowerCased)) { // If given parameter is defined by Oauth1a protocol, add with lower-cased key. builder.put(lowerCased, value); } else { // Otherwise, just add. builder.put(key, value); } } } this.params = builder.build(); if (!this.params.keySet().containsAll(REQUIRED_PARAM_KEYS)) { final Set<String> missing = Sets.difference(REQUIRED_PARAM_KEYS, this.params.keySet()); throw new IllegalArgumentException("Missing OAuth1a parameter exists: " + missing); } try { Long.parseLong(this.params.get(OAUTH_TIMESTAMP)); } catch (NumberFormatException e) { throw new IllegalArgumentException( "Illegal " + OAUTH_TIMESTAMP + " value: " + this.params.get(OAUTH_TIMESTAMP)); } }
/** * Orders the descriptions. * * @return descriptions in order */ public List<Description> order(Collection<Description> descriptions) throws InvalidOrderingException { List<Description> inOrder = ordering.orderItems( Collections.unmodifiableCollection(descriptions)); if (!ordering.validateOrderingIsCorrect()) { return inOrder; } Set<Description> uniqueDescriptions = new HashSet<Description>(descriptions); if (!uniqueDescriptions.containsAll(inOrder)) { throw new InvalidOrderingException("Ordering added items"); } Set<Description> resultAsSet = new HashSet<Description>(inOrder); if (resultAsSet.size() != inOrder.size()) { throw new InvalidOrderingException("Ordering duplicated items"); } else if (!resultAsSet.containsAll(uniqueDescriptions)) { throw new InvalidOrderingException("Ordering removed items"); } return inOrder; }
.entity("Request body must contain a map of { partition:endOffset }") .build(); } else if (!endOffsets.keySet().containsAll(offsets.keySet())) { return Response.status(Response.Status.BAD_REQUEST) .entity( StringUtils.format( "Request contains partitions not being handled by this task, my partitions: %s", endOffsets.keySet() if (entry.getValue().compareTo(nextOffsets.get(entry.getKey())) < 0) { return Response.status(Response.Status.BAD_REQUEST) .entity( "End offset must be >= current offset for partition [%s] (current: %s)", entry.getKey(), nextOffsets.get(entry.getKey())
@Override public Account[] doWork() throws OperationCanceledException, IOException, AuthenticatorException { if (authenticationErrorOnNextResponse) { setAuthenticationErrorOnNextResponse(false); throw new AuthenticatorException(); } List<Account> result = new ArrayList<>(); Account[] accountsByType = getAccountsByType(type); for (Account account : accountsByType) { Set<String> featureSet = accountFeatures.get(account); if (features == null || featureSet.containsAll(Arrays.asList(features))) { result.add(account); } } return result.toArray(new Account[result.size()]); } });
private static void tryDimensionAsMeasures(Collection<FunctionDesc> unmatchedAggregations, CapabilityResult result, Set<TblColRef> dimCols) { Iterator<FunctionDesc> it = unmatchedAggregations.iterator(); while (it.hasNext()) { FunctionDesc functionDesc = it.next(); // let calcite handle count if (functionDesc.isCount()) { it.remove(); continue; } // calcite can do aggregation from columns on-the-fly ParameterDesc parameterDesc = functionDesc.getParameter(); if (parameterDesc == null) { continue; } List<TblColRef> neededCols = parameterDesc.getColRefs(); if (neededCols.size() > 0 && dimCols.containsAll(neededCols) && FunctionDesc.BUILT_IN_AGGREGATIONS.contains(functionDesc.getExpression())) { result.influences.add(new CapabilityResult.DimensionAsMeasure(functionDesc)); it.remove(); continue; } } }
@Override public boolean containsAll(final Collection collection) { Set<Object> values = new HashSet<Object>(); for (final Object o : this) { values.add(o); } return values.containsAll(collection); }
@ExpectWarning("DMI") public static void main(String args[]) { Set s = new HashSet(); s.contains(s); s.remove(s); s.removeAll(s); s.retainAll(s); s.containsAll(s); Map m = new HashMap(); m.get(m); m.remove(m); m.containsKey(m); m.containsValue(m); List lst = new LinkedList(); lst.indexOf(lst); lst.lastIndexOf(lst); }
/** * @param presentedNodes Nodes present in cluster. * @return {@code True} if current topology satisfies baseline. */ public boolean isSatisfied(@NotNull Collection<ClusterNode> presentedNodes) { if (presentedNodes.size() < nodeMap.size()) return false; Set<Object> presentedNodeIds = new HashSet<>(); for (ClusterNode node : presentedNodes) presentedNodeIds.add(node.consistentId()); return presentedNodeIds.containsAll(nodeMap.keySet()); }
/** * @param args */ @ExpectWarning("DMI,GC") public static void main(String args[]) { Set<A> sa = new HashSet<A>(); Set<A> sa2 = new HashSet<A>(); TreeSet<A> tsa2 = new TreeSet<A>(); sa.contains(sa); sa.contains(sa2); sa.contains(tsa2); sa.containsAll(sa); sa.containsAll(sa2); sa.containsAll(tsa2); } }
boolean hasWildcardPermission = permissionSet.contains("*"); if (hasWildcardPermission && !user.getRoleIds().contains(adminRoleId)) { fixedRoleIds.add(adminRoleId); final boolean hasCompleteReaderSet = permissionSet.containsAll(basePermissions); continue; if (hasCompleteReaderSet && !user.getRoleIds().contains(readerRoleId)) { fixedRoleIds.add(readerRoleId);
private static boolean canSelectNext(IfInfo info, BlockNode block) { if (block.getPredecessors().size() == 1) { return true; } if (info.getMergedBlocks().containsAll(block.getPredecessors())) { return true; } return false; }
static void initializePluginsInOrder(Collection<String> disabledPlugins, Iterable<StagemonitorPlugin> plugins) { Set<Class<? extends StagemonitorPlugin>> alreadyInitialized = new HashSet<Class<? extends StagemonitorPlugin>>(); Set<StagemonitorPlugin> notYetInitialized = getPluginsToInit(disabledPlugins, plugins); while (!notYetInitialized.isEmpty()) { int countNotYetInitialized = notYetInitialized.size(); // try to init plugins which are for (Iterator<StagemonitorPlugin> iterator = notYetInitialized.iterator(); iterator.hasNext(); ) { StagemonitorPlugin stagemonitorPlugin = iterator.next(); { final List<Class<? extends StagemonitorPlugin>> dependencies = stagemonitorPlugin.dependsOn(); if (dependencies.isEmpty() || alreadyInitialized.containsAll(dependencies)) { initializePlugin(stagemonitorPlugin); iterator.remove(); alreadyInitialized.add(stagemonitorPlugin.getClass()); } } } if (countNotYetInitialized == notYetInitialized.size()) { // no plugins could be initialized in this try. this probably means there is a cyclic dependency throw new IllegalStateException("Cyclic dependencies detected: " + notYetInitialized); } } }
@Test public void testKeysForSynchronization() throws Exception { final int concurrency = 111; ConcurrencyStrategy<EhcacheEntityMessage> strategy = ConcurrencyStrategies.clusterTierConcurrency(DEFAULT_MAPPER); Set<Integer> visitedConcurrencyKeys = new HashSet<>(); for (int i = -1024; i < 1024; i++) { int concurrencyKey = strategy.concurrencyKey(new ConcurrentTestEntityMessage(i)); assertThat(concurrencyKey, withinRange(DEFAULT_KEY, concurrency)); visitedConcurrencyKeys.add(concurrencyKey); } Set<Integer> keysForSynchronization = strategy.getKeysForSynchronization(); assertThat(keysForSynchronization.contains(DEFAULT_KEY), is(true)); assertThat(keysForSynchronization.containsAll(visitedConcurrencyKeys), is(true)); }
@Override public Void visitIndexJoin(IndexJoinNode node, Set<Symbol> boundSymbols) { node.getProbeSource().accept(this, boundSymbols); node.getIndexSource().accept(this, boundSymbols); Set<Symbol> probeInputs = createInputs(node.getProbeSource(), boundSymbols); Set<Symbol> indexSourceInputs = createInputs(node.getIndexSource(), boundSymbols); for (IndexJoinNode.EquiJoinClause clause : node.getCriteria()) { checkArgument(probeInputs.contains(clause.getProbe()), "Probe symbol from index join clause (%s) not in probe source (%s)", clause.getProbe(), node.getProbeSource().getOutputSymbols()); checkArgument(indexSourceInputs.contains(clause.getIndex()), "Index symbol from index join clause (%s) not in index source (%s)", clause.getIndex(), node.getIndexSource().getOutputSymbols()); } Set<Symbol> lookupSymbols = node.getCriteria().stream() .map(IndexJoinNode.EquiJoinClause::getIndex) .collect(toImmutableSet()); Map<Symbol, Symbol> trace = IndexKeyTracer.trace(node.getIndexSource(), lookupSymbols); checkArgument(!trace.isEmpty() && lookupSymbols.containsAll(trace.keySet()), "Index lookup symbols are not traceable to index source: %s", lookupSymbols); return null; }
for (Assignment assigned : assignment.values()) { for (TopicPartition tp : assigned.partitions()) assignedTopics.add(tp.topic()); if (!assignedTopics.containsAll(allSubscribedTopics)) { Set<String> notAssignedTopics = new HashSet<>(allSubscribedTopics); notAssignedTopics.removeAll(assignedTopics); if (!allSubscribedTopics.containsAll(assignedTopics)) { Set<String> newlyAddedTopics = new HashSet<>(assignedTopics); newlyAddedTopics.removeAll(allSubscribedTopics);
/** * Validates tags and resolves conflicts between user and system tags. */ static boolean applyTags(RuleDto rule, Set<String> tags) { for (String tag : tags) { RuleTagFormat.validate(tag); } Set<String> initialTags = rule.getTags(); final Set<String> systemTags = rule.getSystemTags(); Set<String> withoutSystemTags = Sets.filter(tags, input -> input != null && !systemTags.contains(input)); rule.setTags(withoutSystemTags); return withoutSystemTags.size() != initialTags.size() || !withoutSystemTags.containsAll(initialTags); } }
public void verifyKeySet() { int size = confirmed.size(); boolean empty = confirmed.isEmpty(); assertEquals("keySet should be same size as HashMap's" + "\nTest: " + keySet + "\nReal: " + confirmed.keySet(), size, keySet.size()); assertEquals("keySet should be empty if HashMap is" + "\nTest: " + keySet + "\nReal: " + confirmed.keySet(), empty, keySet.isEmpty()); assertTrue("keySet should contain all HashMap's elements" + "\nTest: " + keySet + "\nReal: " + confirmed.keySet(), keySet.containsAll(confirmed.keySet())); assertEquals("keySet hashCodes should be the same" + "\nTest: " + keySet + "\nReal: " + confirmed.keySet(), confirmed.keySet().hashCode(), keySet.hashCode()); assertEquals("Map's key set should still equal HashMap's", confirmed.keySet(), keySet); }