Tabnine Logo
Map.containsValue
Code IndexAdd Tabnine to your IDE (free)

How to use
containsValue
method
in
java.util.Map

Best Java code snippets using java.util.Map.containsValue (Showing top 20 results out of 16,452)

Refine searchRefine arrow

  • Map.put
  • Map.containsKey
  • Map.get
  • Map.entrySet
  • Map.Entry.getValue
  • Map.Entry.getKey
origin: hankcs/HanLP

@Override
public boolean contains(Object o)
{
  if (o instanceof String)
    return termFrequencyMap.containsKey(o);
  else if (o instanceof TermFrequency)
    return termFrequencyMap.containsValue(o);
  return false;
}
origin: groovy/groovy-core

private static String findNamespaceTag(final Map tagMap, final Object namespaceURI) {
  if (tagMap.containsValue(namespaceURI)) {
    for (Object o : tagMap.entrySet()) {
      final Map.Entry entry = (Map.Entry) o;
      if (namespaceURI.equals(entry.getValue())) {
        return (String) entry.getKey();
      }
    }
  }
  return null;
}
origin: skylot/jadx

private String getValidTagAttributeName(String originalName) {
  if (XMLChar.isValidName(originalName)) {
    return originalName;
  }
  if (tagAttrDeobfNames.containsKey(originalName)) {
    return tagAttrDeobfNames.get(originalName);
  }
  String generated;
  do {
    generated = generateTagAttrName();
  }
  while (tagAttrDeobfNames.containsValue(generated));
  tagAttrDeobfNames.put(originalName, generated);
  return generated;
}
origin: plantuml/plantuml

private String changeWord(final String word) {
  final String lower = word.toLowerCase();
  if (except.contains(lower) || lower.matches("^[a-f0-9]{6}$")) {
    return word;
  }
  String res = convert.get(word);
  if (res != null) {
    return res;
  }
  int len = word.length();
  if (len < 4) {
    len = 4;
  }
  while (true) {
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < len; i++) {
      final char letter = (char) ('a' + rnd.nextInt(26));
      sb.append(letter);
    }
    res = sb.toString();
    if (convert.containsValue(res) == false) {
      convert.put(word, res);
      return res;
    }
  }
}
origin: plutext/docx4j

/**
 * Add the specified mapping if the namespace URI has not been mapped before.
 * 
 * <p>This method will ensure that the mapping is actually unique, that is that
 * the namespace URI correspond to one and only one prefix and that the prefix only
 * corresponds to one and only one namespace URI.
 * 
 * @param uri    The namespace URI to map.
 * @param prefix The prefix to use.
 * 
 * @throws NullPointerException if the URI or prefix is <code>null</code>
 */
public void add(String uri, String prefix) throws NullPointerException {
 if (!this.mappings.containsKey(uri)) {
  int count = 0;
  String actualPrefix = prefix;
  while (this.mappings.containsValue(actualPrefix)) {
   actualPrefix = prefix + count++;
  }
  this.mappings.put(uri, actualPrefix);
 }
}
origin: spotbugs/spotbugs

@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);
}
origin: org.apache.poi/poi

/**
 * If a {@link NameCommentRecord} is added or the name it references
 *  is renamed, then this will update the lookup cache for it.
 *
 * @param commentRecord the comment record
 */
public void updateNameCommentRecordCache(final NameCommentRecord commentRecord) {
  if(commentRecords.containsValue(commentRecord)) {
   for(Entry<String,NameCommentRecord> entry : commentRecords.entrySet()) {
     if(entry.getValue().equals(commentRecord)) {
      commentRecords.remove(entry.getKey());
      break;
     }
   }
  }
  commentRecords.put(commentRecord.getNameText(), commentRecord);
}
origin: skylot/jadx

public void bindArg(RegisterArg arg, BlockNode pred) {
  if (blockBinds.containsValue(pred)) {
    throw new JadxRuntimeException("Duplicate predecessors in PHI insn: " + pred + ", " + this);
  }
  addArg(arg);
  blockBinds.put(arg, pred);
}
origin: google/guava

public void testPutAllExistingKey() {
 final Map<K, V> map;
 final K keyToPut;
 final V valueToPut;
 try {
  map = makePopulatedMap();
  valueToPut = getValueNotInPopulatedMap();
 } catch (UnsupportedOperationException e) {
  return;
 }
 keyToPut = map.keySet().iterator().next();
 final Map<K, V> mapToPut = Collections.singletonMap(keyToPut, valueToPut);
 int initialSize = map.size();
 if (supportsPut) {
  map.putAll(mapToPut);
  assertEquals(valueToPut, map.get(keyToPut));
  assertTrue(map.containsKey(keyToPut));
  assertTrue(map.containsValue(valueToPut));
 } else {
  try {
   map.putAll(mapToPut);
   fail("Expected UnsupportedOperationException.");
  } catch (UnsupportedOperationException expected) {
  }
 }
 assertEquals(initialSize, map.size());
 assertInvariants(map);
}
origin: loklak/loklak_server

String transport = configMap.get("elasticsearch_transport.enabled");
if (transport != null && "true".equals(transport)) {
  String cluster_name = configMap.get("elasticsearch_transport.cluster.name");
  String transport_addresses_string = configMap.get("elasticsearch_transport.addresses");
  if (transport_addresses_string != null && transport_addresses_string.length() > 0) {
  for (Map.Entry<String, String> entry: config.entrySet()) {
    String key = entry.getKey();
    if (key.startsWith("elasticsearch.")) settings.put(key.substring(14), entry.getValue());
boolean noio = configMap.containsValue("noio") && configMap.get("noio").equals("true");
messages = new MessageFactory(noio ? null : elasticsearch_client, IndexName.messages.name(), CACHE_MAXSIZE, EXIST_MAXSIZE);
messages_hour = new MessageFactory(noio ? null : elasticsearch_client, IndexName.messages_hour.name(), CACHE_MAXSIZE, EXIST_MAXSIZE);
origin: Bukkit/Bukkit

public void recalculatePermissionDefaults(Permission perm) {
  if (permissions.containsValue(perm)) {
    defaultPerms.get(true).remove(perm);
    defaultPerms.get(false).remove(perm);
    calculatePermissionDefault(perm);
  }
}
origin: apache/ignite

/**
 * Checks map emptiness.
 *
 * @param map Map to check.
 * @throws Exception If failed.
 */
private void checkEmptyMap(Map<?, ?> map) throws Exception {
  assert map.isEmpty();
  assert !map.containsKey("key");
  assert !map.containsValue("value");
  assertEquals(0, map.size());
  assert map.keySet().isEmpty();
  assert map.entrySet().isEmpty();
  assert map.values().isEmpty();
  assert !map.keySet().iterator().hasNext();
  assert !map.entrySet().iterator().hasNext();
  assert !map.values().iterator().hasNext();
}
origin: Sable/soot

private String getNewPackageNamePart(String oldPackageNamePart) {
 if (oldPackageNamePart != null && oldToNewPackageNames.containsKey(oldPackageNamePart)) {
  return oldToNewPackageNames.get(oldPackageNamePart);
 }
 int size = 5;
 int tries = 0;
 String newPackageNamePart = "";
 while (newPackageNamePart.length() < NameGenerator.NAME_MAX_LENGTH) {
  synchronized (packageNamesMapLock) {
   if (oldToNewPackageNames.containsValue(newPackageNamePart)) {
    return oldToNewPackageNames.get(newPackageNamePart);
   }
   newPackageNamePart = nameGenerator.generateName(size);
   if (!oldToNewPackageNames.containsValue(newPackageNamePart)) {
    final String key = oldPackageNamePart == null ? newPackageNamePart : oldPackageNamePart;
    oldToNewPackageNames.put(key, newPackageNamePart);
    return newPackageNamePart;
   }
  }
  if (tries++ > size) {
   size++;
   tries = 0;
  }
 }
 throw new IllegalStateException("Cannot generate unique package name part: too long for JVM.");
}
origin: plutext/docx4j

/**
 * Method setDefaultPrefix
 *
 * @param namespace
 * @param prefix
 * @throws XMLSecurityException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to set the default prefix
 */
public static void setDefaultPrefix(String namespace, String prefix)
  throws XMLSecurityException {
  JavaUtils.checkRegisterPermission();
  if (prefixMappings.containsValue(prefix)) {
    String storedPrefix = prefixMappings.get(namespace);
    if (!storedPrefix.equals(prefix)) {
      Object exArgs[] = { prefix, namespace, storedPrefix };
      throw new XMLSecurityException("prefix.AlreadyAssigned", exArgs);
    }
  }
  
  if (Constants.SignatureSpecNS.equals(namespace)) {
    XMLUtils.setDsPrefix(prefix);
  }
  if (EncryptionConstants.EncryptionSpecNS.equals(namespace)) {
    XMLUtils.setXencPrefix(prefix);
  }
  prefixMappings.put(namespace, prefix);
}
 
origin: Sable/soot

/**
 * Adds mapping for class name.
 *
 * @param classNameSource
 *          the class name to rename
 * @param classNameTarget
 *          the new class name
 */
public void addClassNameMapping(String classNameSource, String classNameTarget) {
 synchronized (classNamesMapLock) {
  if (!oldToNewClassNames.containsKey(classNameSource) && !oldToNewClassNames.containsValue(classNameTarget)
    && !BodyBuilder.nameList.contains(classNameTarget)) {
   oldToNewClassNames.put(classNameSource, classNameTarget);
   BodyBuilder.nameList.add(classNameTarget);
   return;
  }
 }
 throw new IllegalStateException("Cannot generate unique name: too long for JVM.");
}
origin: stanfordnlp/CoreNLP

public static boolean entityHaveDifferentLocation(Mention m, Mention a, Dictionaries dict) {
 if ((dict.statesAbbreviation.containsKey(a.spanToString()) || dict.statesAbbreviation.containsValue(a.spanToString()))
    && (m.headString.equalsIgnoreCase("country") || m.headString.equalsIgnoreCase("nation"))) {
  return true;
  if (w.get(CoreAnnotations.NamedEntityTagAnnotation.class).equals("LOCATION")) {
   String loc = text;
   if(dict.statesAbbreviation.containsKey(loc)) loc = dict.statesAbbreviation.get(loc);
   locationM.add(lowercased);
  if (w.get(CoreAnnotations.NamedEntityTagAnnotation.class).equals("LOCATION")) {
   String loc = text;
   if(dict.statesAbbreviation.containsKey(loc)) loc = dict.statesAbbreviation.get(loc);
   locationA.add(lowercased);
origin: apache/storm

public static String getJsonWithUpdatedResources(String jsonConf, Map<String, Double> resourceUpdates) {
  try {
    JSONParser parser = new JSONParser();
    Object obj = parser.parse(jsonConf);
    JSONObject jsonObject = (JSONObject) obj;
    Map<String, Double> componentResourceMap =
      (Map<String, Double>) jsonObject.getOrDefault(
        Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, new HashMap<String, Double>()
      );
    for (Map.Entry<String, Double> resourceUpdateEntry : resourceUpdates.entrySet()) {
      if (NormalizedResources.RESOURCE_NAME_NORMALIZER.getResourceNameMapping().containsValue(resourceUpdateEntry.getKey())) {
        // if there will be legacy values they will be in the outer conf
        jsonObject.remove(getCorrespondingLegacyResourceName(resourceUpdateEntry.getKey()));
        componentResourceMap.remove(getCorrespondingLegacyResourceName(resourceUpdateEntry.getKey()));
      }
      componentResourceMap.put(resourceUpdateEntry.getKey(), resourceUpdateEntry.getValue());
    }
    jsonObject.put(Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, componentResourceMap);
    return jsonObject.toJSONString();
  } catch (ParseException ex) {
    throw new RuntimeException("Failed to parse component resources with json: " + jsonConf);
  }
}
origin: apache/drill

/**
 * Mark that a task has become active and should be tracked by its container
 * ID. Prior to this, the task is not associated with a container.
 *
 * @param task
 */
public void containerAllocated(Task task) {
 assert !activeContainers.containsValue(task);
 assert !allocatingTasks.contains(task);
 assert !pendingTasks.contains(task);
 activeContainers.put(task.getContainerId(), task);
 controller.containerAllocated(task);
}
origin: google/guava

public void testPutAllNewKey() {
 final Map<K, V> map = makeEitherMap();
 final K keyToPut;
 final V valueToPut;
 try {
  keyToPut = getKeyNotInPopulatedMap();
  valueToPut = getValueNotInPopulatedMap();
 } catch (UnsupportedOperationException e) {
  return;
 }
 final Map<K, V> mapToPut = Collections.singletonMap(keyToPut, valueToPut);
 if (supportsPut) {
  int initialSize = map.size();
  map.putAll(mapToPut);
  assertEquals(valueToPut, map.get(keyToPut));
  assertTrue(map.containsKey(keyToPut));
  assertTrue(map.containsValue(valueToPut));
  assertEquals(initialSize + 1, map.size());
 } else {
  try {
   map.putAll(mapToPut);
   fail("Expected UnsupportedOperationException.");
  } catch (UnsupportedOperationException expected) {
  }
 }
 assertInvariants(map);
}
origin: ben-manes/caffeine

@Test(dataProvider = "caches")
@CacheSpec(requiresWeakOrSoft = true, expireAfterAccess = Expire.DISABLED,
  expireAfterWrite = Expire.DISABLED, maximumSize = Maximum.DISABLED,
  weigher = CacheWeigher.DEFAULT, population = Population.FULL, stats = Stats.ENABLED,
  removalListener = Listener.CONSUMING)
public void containsValue(Map<Integer, Integer> map, CacheContext context) {
 Integer key = context.firstKey();
 Integer value = context.original().get(key);
 context.clear();
 GcFinalization.awaitFullGc();
 assertThat(map.containsValue(value), is(true));
 key = null;
 GcFinalization.awaitFullGc();
 assertThat(map.containsValue(value), is(not(context.isWeakKeys())));
}
java.utilMapcontainsValue

Javadoc

Returns whether this Map contains the specified value.

Popular methods of Map

  • put
    Maps the specified key to the specified value.
  • get
  • entrySet
    Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes t
  • containsKey
    Returns whether this Map contains the specified key.
  • keySet
    Returns a set of the keys contained in this Map. The Set is backed by this Map so changes to one are
  • values
    Returns a Collection view of the values contained in this map. The collection is backed by the map,
  • remove
  • size
    Returns the number of mappings in this Map.
  • isEmpty
    Returns true if this map contains no key-value mappings.
  • clear
    Removes all elements from this Map, leaving it empty.
  • putAll
    Copies all of the mappings from the specified map to this map (optional operation). The effect of th
  • forEach
  • putAll,
  • forEach,
  • equals,
  • computeIfAbsent,
  • hashCode,
  • getOrDefault,
  • putIfAbsent,
  • compute,
  • merge

Popular in Java

  • Making http post requests using okhttp
  • getContentResolver (Context)
  • getResourceAsStream (ClassLoader)
  • findViewById (Activity)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now