Java Code Examples for com.google.common.collect.SetMultimap#containsKey()

The following examples show how to use com.google.common.collect.SetMultimap#containsKey() . 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 File: ConditionalEdges.java    From bazel with Apache License 2.0 6 votes vote down vote up
/** Builds ConditionalEdges from given graph. */
public ConditionalEdges(Digraph<Target> graph) {
  this.map = new HashMap<>();

  for (Node<Target> node : graph.getNodes()) {
    Rule rule = node.getLabel().getAssociatedRule();
    if (rule == null) {
      // rule is null for source files and package groups. Skip them.
      continue;
    }

    SetMultimap<Label, Label> conditions = getAllConditions(rule, RawAttributeMapper.of(rule));
    if (conditions.isEmpty()) {
      // bail early for most common case of no conditions in the rule.
      continue;
    }

    Label nodeLabel = node.getLabel().getLabel();
    for (Node<Target> succ : node.getSuccessors()) {
      Label successorLabel = succ.getLabel().getLabel();
      if (conditions.containsKey(successorLabel)) {
        insert(nodeLabel, successorLabel, conditions.get(successorLabel));
      }
    }
  }
}
 
Example 2
Source File: EntityListenersService.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Removes an entity listener for a entity of the given class
 *
 * @param entityListener entity listener for a entity
 * @return boolean
 */
public boolean removeEntityListener(String repoFullName, EntityListener entityListener) {
  lock.writeLock().lock();
  try {
    verifyRepoRegistered(repoFullName);
    SetMultimap<Object, EntityListener> entityListeners =
        this.entityListenersByRepo.get(repoFullName);
    if (entityListeners.containsKey(entityListener.getEntityId())) {
      entityListeners.remove(entityListener.getEntityId(), entityListener);
      return true;
    }
    return false;
  } finally {
    lock.writeLock().unlock();
  }
}
 
Example 3
Source File: RegisterServiceImpl.java    From qconfig with MIT License 5 votes vote down vote up
private Set<QConfigServer> serversInPriority(String room, SetMultimap<String, QConfigServer> roomServerMap) {
    if (roomServerMap.containsKey(room)) {
        return roomServerMap.get(room);
    } else if (roomServerMap.containsKey(serverStore.defaultRoom())) {
        return roomServerMap.get(serverStore.defaultRoom());
    } else {
        return ImmutableSet.copyOf(roomServerMap.asMap().entrySet().iterator().next().getValue());
    }
}
 
Example 4
Source File: FusingAndroidManifestMerger.java    From bundletool with Apache License 2.0 5 votes vote down vote up
@Override
public AndroidManifest merge(SetMultimap<BundleModuleName, AndroidManifest> manifests) {
  if (!manifests.containsKey(BASE_MODULE_NAME)) {
    throw CommandExecutionException.builder()
        .withInternalMessage("Expected to have base module.")
        .build();
  }
  return merge(ensureOneManifestPerModule(manifests));
}
 
Example 5
Source File: PluginManager.java    From raml-java-tools with Apache License 2.0 5 votes vote down vote up
private static void buildPluginNames(SetMultimap<String, Class<?>> info, Properties properties) {

    for (String name : properties.stringPropertyNames()) {

      List<Class<?>> classList = classList(name, properties.getProperty(name));
      if (info.containsKey(name)) {

        throw new GenerationException("duplicate name in plugins: " + name);
      }
      info.putAll(name, classList);
    }
  }
 
Example 6
Source File: Actions.java    From bazel-buildfarm with Apache License 2.0 5 votes vote down vote up
private static boolean satisfiesRequirement(
    SetMultimap<String, String> provisions, String requirement, String value) {
  if (requirement.equals("min-cores")) {
    if (!provisions.containsKey("cores")) {
      return false;
    }
    int mincores = Integer.parseInt(value);
    int cores = Integer.parseInt(Iterables.getOnlyElement(provisions.get("cores")));
    return cores >= mincores;
  }
  if (requirement.equals("max-cores")) {
    return true;
  }
  return provisions.containsEntry(requirement, value);
}
 
Example 7
Source File: AbstractAnchor.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private void updatePositions(Node anchored) {
	SetMultimap<Node, AnchorKey> keys = getKeysByNode();
	if (keys.containsKey(anchored)) {
		Set<AnchorKey> keysCopy = new HashSet<>(keys.get(anchored));
		for (AnchorKey key : keysCopy) {
			updatePosition(key);
		}
	}
}
 
Example 8
Source File: BaggageImpl.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Does this baggage contain anything for the specified key?
 * 
 * @param namespace The namespace the key resides in
 * @param key The key to look up
 * @return true if the baggage has one or more value for this namespace and key */
public boolean contains(ByteString namespace, ByteString key) {
    if (namespace != null && key != null) {
        SetMultimap<ByteString, ByteString> namespaceData = contents.get(namespace);
        return namespaceData != null && namespaceData.containsKey(key);
    }
    return false;
}
 
Example 9
Source File: WaitCoalescer.java    From swift-t with Apache License 2.0 5 votes vote down vote up
public boolean tryPushdownClosedVar(Logger logger, Block top,
    ExecContext topContext, StackLite<Continuation> ancestors, Block curr,
    ExecContext currContext, SetMultimap<Var, InstOrCont> waitMap,
    ArrayList<Continuation> pushedDown, ListIterator<Statement> it,
    Var v) {
  boolean changed = false;
  if (waitMap.containsKey(v)) {
    Pair<Boolean, Set<Continuation>> pdRes =
        relocateDependentInstructions(logger, top, topContext, ancestors,
                                  curr, currContext, it,  waitMap, v);
    changed = pdRes.val1;
    pushedDown.addAll(pdRes.val2);
  }
  return changed;
}
 
Example 10
Source File: SetMultimapExpression.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public boolean containsKey(Object key) {
	final SetMultimap<K, V> setMultimap = get();
	return (setMultimap == null) ? EMPTY_SETMULTIMAP.containsKey(key)
			: setMultimap.containsKey(key);
}