public boolean isEmpty() { return listMultimap.isEmpty(); }
protected void assertGet(K key, Collection<V> values) { assertEqualInOrder(values, multimap().get(key)); if (!values.isEmpty()) { assertEqualInOrder(values, multimap().asMap().get(key)); assertFalse(multimap().isEmpty()); } else { assertNull(multimap().asMap().get(key)); } assertEquals(values.size(), multimap().get(key).size()); assertEquals(values.size() > 0, multimap().containsKey(key)); assertEquals(values.size() > 0, multimap().keySet().contains(key)); assertEquals(values.size() > 0, multimap().keys().contains(key)); } }
@Override public ListMultimap<Thread, ID> lockOrDetectPotentialLocksCycle() { final Thread currentThread = Thread.currentThread(); synchronized (CycleDetectingLockFactory.class) { checkState(); // Add this lock to the waiting map to ensure it is included in any reported lock cycle. lockThreadIsWaitingOn.put(currentThread, this); ListMultimap<Thread, ID> locksInCycle = detectPotentialLocksCycle(); if (!locksInCycle.isEmpty()) { // We aren't actually going to wait for this lock, so remove it from the map. lockThreadIsWaitingOn.remove(currentThread); // potential deadlock is found, we don't try to take this lock return locksInCycle; } } // this may be blocking, but we don't expect it to cause a deadlock lockImplementation.lock(); synchronized (CycleDetectingLockFactory.class) { // current thread is no longer waiting on this lock lockThreadIsWaitingOn.remove(currentThread); checkState(); // mark it as owned by us lockOwnerThread = currentThread; lockReentranceCount++; // add this lock to the list of locks owned by a current thread locksOwnedByThread.put(currentThread, this); } // no deadlock is found, locking successful return ImmutableListMultimap.of(); }
ListMultimap<String, ComponentDto> componentsPerQualifier = authorizedComponents.stream() .collect(MoreCollectors.index(ComponentDto::qualifier)); if (componentsPerQualifier.isEmpty()) { return newBuilder().build();
if (setters.isEmpty()) { return Description.NO_MATCH;
while (!pendingPrefabs.isEmpty()) { Iterator<Map.Entry<String, Collection<EntityData.Prefab>>> i = pendingPrefabs.asMap().entrySet().iterator(); while (i.hasNext()) {
@Override public Optional<Text> getHelp(CommandSource source) { if (this.commands.isEmpty()) { return Optional.empty(); } Text.Builder build = t("Available commands:\n").toBuilder(); for (Iterator<String> it = filterCommands(source).iterator(); it.hasNext();) { final Optional<CommandMapping> mappingOpt = get(it.next(), source); if (!mappingOpt.isPresent()) { continue; } CommandMapping mapping = mappingOpt.get(); final Optional<Text> description = mapping.getCallable().getShortDescription(source); build.append(Text.builder(mapping.getPrimaryAlias()) .color(TextColors.GREEN) .style(TextStyles.UNDERLINE) .onClick(TextActions.suggestCommand("/" + mapping.getPrimaryAlias())).build(), SPACE_TEXT, description.orElse(mapping.getCallable().getUsage(source))); if (it.hasNext()) { build.append(Text.NEW_LINE); } } return Optional.of(build.build()); }
if (!present.isEmpty()) { StringBuilder presentDescription = new StringBuilder(); for (E excludedItem : present.keySet()) {
creationLock.lockOrDetectPotentialLocksCycle(); if (locksCycle.isEmpty()) {
return new ModificationSummary(!mutations.isEmpty(),has2iMods);
private IndexingResult doIndexIssueItems(DbSession dbSession, ListMultimap<String, EsQueueDto> itemsByIssueKey) { if (itemsByIssueKey.isEmpty()) { return new IndexingResult(); } IndexingListener listener = new OneToOneResilientIndexingListener(dbClient, dbSession, itemsByIssueKey.values()); BulkIndexer bulkIndexer = createBulkIndexer(Size.REGULAR, listener); bulkIndexer.start(); try (IssueIterator issues = issueIteratorFactory.createForIssueKeys(itemsByIssueKey.keySet())) { while (issues.hasNext()) { IssueDoc issue = issues.next(); bulkIndexer.add(newIndexRequest(issue)); itemsByIssueKey.removeAll(issue.getId()); } } // the remaining uuids reference issues that don't exist in db. They must // be deleted from index. itemsByIssueKey.values().forEach( item -> bulkIndexer.addDeletion(INDEX_TYPE_ISSUE, item.getDocId(), item.getDocRouting())); return bulkIndexer.stop(); }
return new ModificationSummary(!mutations.isEmpty(),has2iMods);
private IndexingResult doIndexProjectItems(DbSession dbSession, ListMultimap<String, EsQueueDto> itemsByProjectUuid) { if (itemsByProjectUuid.isEmpty()) { return new IndexingResult(); } // one project, referenced by es_queue.doc_id = many issues IndexingListener listener = new OneToManyResilientIndexingListener(dbClient, dbSession, itemsByProjectUuid.values()); BulkIndexer bulkIndexer = createBulkIndexer(Size.REGULAR, listener); bulkIndexer.start(); for (String projectUuid : itemsByProjectUuid.keySet()) { // TODO support loading of multiple projects in a single SQL request try (IssueIterator issues = issueIteratorFactory.createForProject(projectUuid)) { if (issues.hasNext()) { do { IssueDoc doc = issues.next(); bulkIndexer.add(newIndexRequest(doc)); } while (issues.hasNext()); } else { // project does not exist or has no issues. In both case // all the documents related to this project are deleted. addProjectDeletionToBulkIndexer(bulkIndexer, projectUuid); } } } return bulkIndexer.stop(); }
assertTrue(ArbitraryInstances.get(ImmutableClassToInstanceMap.class).isEmpty()); assertTrue(ArbitraryInstances.get(ClassToInstanceMap.class).isEmpty()); assertTrue(ArbitraryInstances.get(ListMultimap.class).isEmpty()); assertTrue(ArbitraryInstances.get(ImmutableListMultimap.class).isEmpty()); assertTrue(ArbitraryInstances.get(SetMultimap.class).isEmpty());
if (!statementProps.isEmpty()) { Collection<Pair<String,Object>> propsList = statementProps.get(QueryConstants.ALL_FAMILY_PROPERTIES_KEY); for (Pair<String,Object> prop : propsList) {
/** {@inheritDoc} */ @Override protected boolean allowNullAttributeContext() { return attributeValueMap.isEmpty(); }
/** * @return True iff any of the following methods have been called: * <ul> * <li>{@link #addInvokeBefore(MetaMethod, Statement)}, * <li>{@link #addInvokeAfter(MetaMethod, Statement)}, * <li>{@link #addProxyProperty(String, Class, Statement)}. * </ul> */ public boolean requiresProxy() { return !(proxyProperties.isEmpty() && invokeAfter.isEmpty() && invokeBefore.isEmpty()); }
if (!statement.getProps().isEmpty()) { for (String familyName : statement.getProps().keySet()) { if (!familyName.equals(QueryConstants.ALL_FAMILY_PROPERTIES_KEY)) {