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:net.sourceforge.pmd.properties.ValueParserConstants.java

static <T> ValueParser<T> enumerationParser(final Map<String, T> mappings) {

    if (mappings.containsValue(null)) {
        throw new IllegalArgumentException("Map may not contain entries with null values");
    }/*from   www .ja v a2  s. com*/

    return new ValueParser<T>() {
        @Override
        public T valueOf(String value) throws IllegalArgumentException {
            if (!mappings.containsKey(value)) {
                throw new IllegalArgumentException("Value was not in the set " + mappings.keySet());
            }
            return mappings.get(value);
        }
    };
}

From source file:com.hangum.tadpole.mongodb.core.utils.MongoDBTableColumn.java

/**
 * TableView?   ? ?. /* w w w . j  ava  2  s  .  c om*/
 *
 * @param dbObject
 * @param mapColumns
 * @return
 */
public static Map<Integer, String> getTabelColumnView(DBObject dbObject, Map<Integer, String> mapColumns) {
    if (dbObject == null)
        return mapColumns;

    int i = mapColumns.size();
    for (String name : dbObject.keySet()) {
        if (!mapColumns.containsValue(name)) {
            mapColumns.put(i, name);
            i++;
        }
    }

    return mapColumns;
}

From source file:Main.java

/**
 * Extracts dynamic namespaces that are inline inside a XPath expression. Example:
 * <code>/{http://sample.org/foo}foo/{http://sample.org/bar}bar</code>
 * @param expression//from   w w  w  .  j a  va2s.c om
 * @return
 */
public static Map<String, String> getDynamicNamespaces(String expression) {
    Map<String, String> namespaces = new HashMap<String, String>();

    if (expression.contains(DYNAMIC_NS_START) && expression.contains(DYNAMIC_NS_END)) {
        String[] tokens = expression.split("\\" + DYNAMIC_NS_START);

        for (int i = 1; i < tokens.length; i++) {
            String namespace = tokens[i].substring(0, tokens[i].indexOf(DYNAMIC_NS_END));

            if (!namespaces.containsValue(namespace)) {
                namespaces.put(DYNAMIC_NS_PREFIX + i, namespace);
            }
        }
    }

    return namespaces;
}

From source file:com.aurel.track.exchange.docx.exporter.StyleUtil.java

/**
 * Gets the configured or a default style which is present in the styles map
 * @param stylesMap/*  w  ww. ja v  a2  s  .c o  m*/
 * @param configuredStyle
 * @param styleKey
 * @param defaultStyle
 * @return
 */
public static String getStyle(Map<String, String> stylesMap, String configuredStyle, String styleKey,
        String defaultStyleName) {
    if (configuredStyle == null || "".equals(configuredStyle)) {
        LOGGER.info("No " + styleKey + " specified in GeneralSettings.properties");
    } else {
        if (!stylesMap.containsValue(configuredStyle)) {
            LOGGER.info("The " + styleKey
                    + " specified in GeneralSettings.properties is not found as paragraph style in the template");
            if (stylesMap.containsKey(configuredStyle)) {
                //styleID could be language specific while style name not. So if the same Genji instance is used in more locales there could be different 
                //docx templates in different languages, in this case probably is better to specify the style name instead of the style ID
                //if the style name is reused in all templates for the same formatting of the parts
                configuredStyle = stylesMap.get(configuredStyle);
                LOGGER.info("The " + styleKey
                        + " specified in GeneralSettings.properties is found as paragraph name in the template. Return the paragraph style "
                        + configuredStyle);
                return configuredStyle;
            }
        } else {
            return configuredStyle;
        }
    }
    if (stylesMap.containsKey(defaultStyleName)) {
        //as default we always get the style by name (locale independent) and not by styleID
        configuredStyle = stylesMap.get(defaultStyleName);
        LOGGER.info("Fall back to " + configuredStyle);
        return configuredStyle;
    }
    return null;
}

From source file:org.geoserver.wfs.notification.GMLNotificationSerializer.java

private static void loadNamespaceBindings(NamespaceSupport nss, XSDSchema schema, XSDSchema exclude) {
    Map excludePrefixes = exclude.getQNamePrefixToNamespaceMap();
    for (Map.Entry<String, String> e : ((Map<String, String>) schema.getQNamePrefixToNamespaceMap())
            .entrySet()) {/*  w  w  w  . j  av a 2  s  .c  o m*/
        if (excludePrefixes.containsKey(e.getKey()) || excludePrefixes.containsValue(e.getValue())) {
            continue;
        }
        String pref = e.getKey();
        nss.declarePrefix(pref == null ? "" : pref, e.getValue());
    }
}

From source file:info.archinnov.achilles.internals.parser.validator.BeanValidator.java

public static void validateNoDuplicateNames(AptUtils aptUtils, TypeName rawClassType,
        List<TypeParsingResult> parsingResults) {
    Map<String, String> mapping = new HashMap<>();
    parsingResults.stream().map(x -> x.context).forEach(context -> {
        final String fieldName = context.fieldName;
        final String cqlColumn = context.cqlColumn;
        if (mapping.containsKey(fieldName)) {
            aptUtils.printError("The class '%s' already contains a field with name '%s'", rawClassType,
                    fieldName);//w  ww . java2 s  .  c o m
        } else if (mapping.containsValue(cqlColumn)) {
            aptUtils.printError("The class '%s' already contains a cql column with name '%s'", rawClassType,
                    cqlColumn);
        } else {
            mapping.put(fieldName, cqlColumn);
        }
    });
}

From source file:edu.tum.cs.conqat.quamoco.qiesl.QIESLEngine.java

/**
 * Converts expression with model names to expression with technical names.
 * If a model name cannot be resolved a {@link QIESLException} is thrown.
 */// w w w. j  a  va2  s  .  c o m
protected static String toTechnicalExpression(String expression, Map<String, String> nameMapping)
        throws QIESLException {
    Matcher matcher = PATTERN_FOR_MEASURE_NAMES.matcher(expression);
    StringBuffer result = new StringBuffer();
    while (matcher.find()) {
        String match = matcher.group(1);
        if (!nameMapping.containsValue(match)) {
            throw new QIESLException("Unknown variable '" + match + "' in spec;" + " available names are '"
                    + nameMapping.values() + "'");
        }
        String replacement = toTechnicalName(match);
        matcher.appendReplacement(result, StringUtils.escapeRegexReplacementString(replacement));
    }
    matcher.appendTail(result);
    return result.toString();
}

From source file:org.wso2.carbon.governance.registry.extensions.executors.utils.Utils.java

public static void makeDependencies(RequestContext requestContext, Map<String, String> parameterMap,
        Map<String, String> oldPathNewPathMap) throws RegistryException {

    Registry registry = requestContext.getRegistry();

    if (!CommonUtil.isAddingAssociationLockAvailable()) {
        return;//  w ww .  j av a2 s  .  c om
    }
    CommonUtil.acquireAddingAssociationLock();
    try {
        for (Map.Entry<String, String> entry : oldPathNewPathMap.entrySet()) {
            Association[] associations = registry.getAllAssociations(entry.getValue());
            for (Association association : associations) {
                if (!(oldPathNewPathMap.containsValue(association.getSourcePath()))
                        || !(oldPathNewPathMap.containsValue(association.getDestinationPath()))) {
                    registry.removeAssociation(association.getSourcePath(), association.getDestinationPath(),
                            association.getAssociationType());
                }
            }
        }
        for (Map.Entry<String, String> keyValueSet : parameterMap.entrySet()) {
            Association[] associations = registry.getAllAssociations(keyValueSet.getKey());
            for (Association association : associations) {
                if (oldPathNewPathMap.containsKey(association.getDestinationPath())
                        && oldPathNewPathMap.containsKey(association.getSourcePath())) {
                    registry.addAssociation(oldPathNewPathMap.get(association.getSourcePath()),
                            oldPathNewPathMap.get(association.getDestinationPath()),
                            association.getAssociationType());
                }
            }
        }
    } finally {
        CommonUtil.releaseAddingAssociationLock();
    }
}

From source file:org.grails.datastore.gorm.jpa.GormToJpaTransform.java

static void handleToOne(ClassNode classNode, Map<String, ClassNode> belongsToMap, String propertyName) {
    ClassNode associatedClass = belongsToMap.get(propertyName);

    final Map<String, ClassNode> inverseHasManyMap = lookupStringToClassNodeMap(associatedClass,
            GrailsDomainClassProperty.HAS_MANY);
    final Map<String, ClassNode> inverseHasOneMap = lookupStringToClassNodeMap(associatedClass,
            GrailsDomainClassProperty.HAS_ONE);

    if (inverseHasManyMap.containsValue(classNode)) {
        for (String inversePropertyName : inverseHasManyMap.keySet()) {
            if (classNode.equals(inverseHasManyMap.get(inversePropertyName))) {
                final AnnotationNode manyToOneAnnotation = new AnnotationNode(new ClassNode(ManyToOne.class));
                manyToOneAnnotation.addMember("cascade", EXPR_CASCADE_PERSIST);
                annotateProperty(classNode, propertyName, manyToOneAnnotation);
            }/*from  w  w w.  j  a v a2  s  . com*/
        }
    } else if (inverseHasOneMap.containsValue(classNode)) {
        for (String inversePropertyName : inverseHasOneMap.keySet()) {
            if (classNode.equals(inverseHasOneMap.get(inversePropertyName))) {
                final AnnotationNode oneToOneAnnotation = new AnnotationNode(new ClassNode(OneToOne.class));
                oneToOneAnnotation.addMember("mappedBy", new ConstantExpression(inversePropertyName));
                annotateProperty(classNode, propertyName, oneToOneAnnotation);
            }
        }
    } else {
        AnnotationNode annotationNode = new AnnotationNode(new ClassNode(ManyToOne.class));
        annotationNode.addMember("cascade", EXPR_CASCADE_ALL);
        annotateProperty(classNode, propertyName, annotationNode);
    }
}

From source file:fuzzy.util.TestMaxMF.java

@Test
public void testMaxMF() {
    Collection<Double> values = new DoubleRange(-10.0, 30.0, 0.1).toCollection();
    MembershipFunction<Double> mf = new TrapezoidalMembershipFunction(-5.0, -2.0, 10.0, 20.0);
    Map<Double, Double> r = MaxMF.of(values, mf);

    assertTrue(r.containsValue(Double.valueOf(1.0)));
}