Example usage for java.util Map containsValue

List of usage examples for java.util Map containsValue

Introduction

In this page you can find the example usage for java.util Map containsValue.

Prototype

boolean containsValue(Object value);

Source Link

Document

Returns true if this map maps one or more keys to the specified value.

Usage

From source file:org.eclipse.gemini.blueprint.service.dependency.internal.DefaultMandatoryDependencyManager.java

private boolean checkIfExporterShouldStart(Object exporter, Map<Object, Boolean> importers) {

    if (!importers.containsValue(Boolean.FALSE)) {
        startExporter(exporter);/*w  w  w . ja v  a 2  s .  c om*/

        if (log.isDebugEnabled())
            log.trace("Exporter [" + exporterToName.get(exporter) + "] started; "
                    + "all its dependencies are satisfied");
        return true;

    } else {
        List<String> unsatisfiedDependencies = new ArrayList<String>(importers.size());

        for (Iterator<Map.Entry<Object, Boolean>> iterator = importers.entrySet().iterator(); iterator
                .hasNext();) {
            Map.Entry<Object, Boolean> entry = iterator.next();
            if (Boolean.FALSE.equals(entry.getValue()))
                unsatisfiedDependencies.add(importerToName.get(entry.getKey()));
        }

        if (log.isTraceEnabled()) {
            log.trace("Exporter [" + exporterToName.get(exporter)
                    + "] not started; there are still unsatisfied dependencies " + unsatisfiedDependencies);
        }

        return false;
    }
}

From source file:com.fredhopper.core.connector.index.generate.validator.SetAttributeValidator.java

@Override
protected void validateValue(final FhAttributeData attribute,
        final List<com.fredhopper.core.connector.index.report.Violation> violations) {
    final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues();
    for (final Optional<String> valueId : values.rowKeySet()) {
        final Map<Optional<Locale>, String> valueMap = values.row(valueId);
        if (CollectionUtils.isEmpty(valueMap) || valueMap.containsKey(Optional.empty())
                || valueMap.containsKey(null)) {
            rejectValue(attribute, violations, "The \"set\" attribute Locale key must be set.");
            return;
        }/*from   w  ww .j  a  va  2  s  .  co m*/
        if (valueMap.containsValue(null) || valueMap.containsValue("")) {
            rejectValue(attribute, violations, "The \"set\" attribute value must not be blank.");
            return;
        }
    }
}

From source file:org.nanocom.console.input.ArgsInput.java

/**
 * Returns true if the raw parameters (not parsed) contain a value.
 *
 * This method is to be used to introspect the input parameters
 * before they have been validated. It must be used carefully.
 *
 * @param values The values to look for in the raw parameters
 *
 * @return True if the values are contained in the raw parameters
 *///from  w ww .  j a  va 2s.  c  om
@Override
public boolean hasParameterOption(Map<String, String> values) {
    for (String value : tokens) {
        if (values.containsValue(value)) {
            return true;
        }
    }

    return false;
}

From source file:com.livinglogic.utils.AbstractMapChain.java

public boolean containsValue(Object value) {
    boolean containsValue = first.containsValue(value);
    if (!containsValue) {
        Map<K, V> second = getSecond();
        if (second != null)
            containsValue = second.containsValue(value);
    }//from w ww  .  j  ava  2s.  c  o  m
    return containsValue;
}

From source file:org.jclouds.blobstore.integration.internal.BaseMapIntegrationTest.java

/**
 * containsValue() uses eTag comparison to bucket contents, so this can be subject to eventual
 * consistency problems.//from   w  ww.ja  v  a 2 s.c o m
 */
protected void assertConsistencyAwareContainsValue(final Map<String, V> map, final Object value)
        throws InterruptedException {
    assertConsistencyAware(new Runnable() {
        public void run() {
            assert map.containsValue(value);
        }
    });
}

From source file:org.esco.portlet.changeetab.service.impl.CachingEtablissementServiceTest.java

@Test
public void testRetrieveOneExistingEtab() throws Exception {
    final Collection<String> uais = new ArrayList<String>();
    uais.add(CachingEtablissementServiceTest.UAI_2);

    final Map<String, Etablissement> etabs = this.service.retrieveEtablissementsByCodes(uais);

    Assert.assertNotNull("Should return an empty collection !", etabs);
    Assert.assertEquals("Should return only one etab !", 1, etabs.size());
    Assert.assertTrue("Bad etab returned !", etabs.containsValue(CachingEtablissementServiceTest.ETAB_2));
}

From source file:com.fredhopper.core.connector.index.generate.validator.ListAttributeValidator.java

@Override
protected void validateValue(final FhAttributeData attribute, final List<Violation> violations) {
    final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues();
    for (final Optional<String> valueId : values.rowKeySet()) {
        final Map<Optional<Locale>, String> valueMap = values.row(valueId);
        if (CollectionUtils.isEmpty(valueMap) || valueMap.keySet().size() != 1
                || valueMap.containsKey(Optional.empty()) || valueMap.containsKey(null)) {
            rejectValue(attribute, violations, "The \"list\" attribute value unique Locale key must be set.");
            return;
        }//from  ww  w .j a  v  a  2 s.co  m
        if (valueMap.containsValue(null) || valueMap.containsValue("")) {
            rejectValue(attribute, violations, "The \"list\" attribute value must not be blank.");
            return;
        }
    }
}

From source file:net.sf.firemox.database.Proxy.java

/**
 * Return the referenced value of this proxy. If this proxy do not define the
 * named alias, return the given <param>localValue</param>.
 * //  w  w w  . j  a  v a2 s.c  o m
 * @param nameSpace
 * @param localValue
 * @return the referenced value of this proxy.
 */
public String getLocalValueFromGlobal(String nameSpace, String localValue) {
    final Map<String, String> alias = aliases.get(nameSpace);
    if (alias != null && alias.containsValue(localValue.toLowerCase())) {
        for (Map.Entry<String, String> entry : alias.entrySet()) {
            if (entry.getValue().equals(localValue.toLowerCase())) {
                return entry.getKey();
            }
        }
    }
    return localValue;
}

From source file:org.esco.portlet.changeetab.service.impl.CachingEtablissementServiceTest.java

@Test
public void testRetrieveSeveralExistingEtabs() throws Exception {
    final Collection<String> uais = new ArrayList<String>();
    uais.add(CachingEtablissementServiceTest.UAI_3);
    uais.add(CachingEtablissementServiceTest.UAI_1);

    final Map<String, Etablissement> etabs = this.service.retrieveEtablissementsByCodes(uais);

    Assert.assertNotNull("Should return an empty collection !", etabs);
    Assert.assertEquals("Should return only one etab !", 2, etabs.size());
    Assert.assertTrue("Bad etab in returned list !",
            etabs.containsValue(CachingEtablissementServiceTest.ETAB_1));
    Assert.assertTrue("Bad etab in returned list !",
            etabs.containsValue(CachingEtablissementServiceTest.ETAB_3));
}

From source file:de.hybris.platform.test.CaseInsensitiveStringMapTest.java

@Test
public void testValues() {
    final Set<String> values = new HashSet<String>(//
            Arrays.asList("AAA", "BBB", "CCC", "ddd", "x", "y", "\u00df", "\u00dc", ""));

    final Set<String> wrongValues = new HashSet<String>(//
            Arrays.asList("aaa", "bbb", "ccc", "ddd", "x", "y", "\u00df", "\u00dc", ""));

    final Map<String, String> testMap = new CaseInsensitiveStringMap<String>();

    for (final String v : values) {
        testMap.put(v, v);/*from  w ww . j a  v a 2s. com*/
    }

    Assert.assertTrue(testMap.containsValue("AAA"));
    Assert.assertFalse(testMap.containsValue("aaa"));

    Assert.assertEquals(values, new HashSet<String>(testMap.values()));
    Assert.assertFalse(wrongValues.equals(new HashSet<String>(testMap.values())));
}