/** * Returns the key/value mapping best matching specified criterion. * * @param storage namespace storage * @param criterion selection criterion * @return Selected mapping, if available. */ public final Optional<Entry<K, V>> getFrom(final NamespaceStorageNode storage, final NamespaceKeyCriterion<K> criterion) { final Map<K, V> mappings = getAllFrom(storage); if (mappings == null) { return Optional.empty(); } Entry<K, V> match = null; for (Entry<K, V> entry : mappings.entrySet()) { final K key = entry.getKey(); if (criterion.match(key)) { if (match != null) { final K selected = criterion.select(match.getKey(), key); if (selected.equals(match.getKey())) { continue; } Verify.verify(selected == key, "Criterion %s selected invalid key %s from candidates [%s %s]", selected, match.getKey(), key); } match = entry; } } return Optional.ofNullable(match); }
@Override public final String toString() { return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString(); }
@Override boolean onValueAdded(final K key, final V value) { if (criterion.match(key)) { LOG.debug("Listener on {} criterion {} matched added key {}", type, criterion, key); waitForPhase(value, type, phase, criterion, listener); return true; } return false; } });
if (revision == null) { requiresCtxPrerequisite = includeAction.requiresCtx(stmt, SubmoduleNamespace.class, NamespaceKeyCriterion.latestRevisionModule(submoduleName), SOURCE_LINKAGE); } else { requiresCtxPrerequisite = includeAction.requiresCtx(stmt, SubmoduleNamespace.class,
if (revision == null) { imported = importAction.requiresCtx(stmt, ModuleNamespace.class, NamespaceKeyCriterion.latestRevisionModule(moduleName), SOURCE_LINKAGE); } else { imported = importAction.requiresCtx(stmt, ModuleNamespace.class,