Example usage for java.util Map remove

List of usage examples for java.util Map remove

Introduction

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

Prototype

V remove(Object key);

Source Link

Document

Removes the mapping for a key from this map if it is present (optional operation).

Usage

From source file:Main.java

public static void remove(String key) {
    Map<String, Object> map = wfThreadLocal.get();
    if (map != null) {
        map.remove(key);
    }//from   www  .  ja v a 2s  .c  o  m
}

From source file:Main.java

/**
 * Rename key1 by key2 in map, for example, if We have the follow code:<br>
 *     <pre>//from  w w  w. j  ava  2s  . c o  m
 *         Map<Strin, String> map = new HashMap<>();
 *         map.put("key1", "value1");
 *         CollectionsUtils.renameKey( map, "key1", "key2");
 *         System.out.println( map.get("key1") + " " + map.get("key2"));
 *     </pre>
 *
 * The output will be <pre>value1 null</pre>
 * 
 * @param map map where the key have to be replace
 * @param key1 key to replace
 * @param key2 new key
 * @param <K>
 * @param <V>
 */
public static <K, V> void renameKey(Map<K, V> map, K key1, K key2) {
    V emailaddress = map.get(key1);
    map.remove(key1);
    map.put(key2, emailaddress);
}

From source file:Main.java

public static <T> List<T> mapToList(Map<String, T> map, String... excludeKey) {
    Map<String, T> tmpMap = new LinkedHashMap<String, T>(map);
    for (String exclude : excludeKey) {
        tmpMap.remove(exclude);
    }/*  ww  w .ja  v a 2s .co m*/
    List<T> list = new ArrayList<>();
    for (Map.Entry<String, T> entry : tmpMap.entrySet()) {
        list.add(entry.getValue());
    }
    return list;
}

From source file:Main.java

public static void removeKeys(Collection keys, Map map) {
    for (Iterator i = keys.iterator(); i.hasNext();) {
        Object key = (Object) i.next();
        map.remove(key);
    }/*from  w ww. jav  a 2s .com*/
}

From source file:Main.java

public static <T> boolean removeByValue(Map<?, T> map, T value) {
    for (Map.Entry<?, T> o : map.entrySet()) {
        if (o.getValue() == value) {
            map.remove(o.getKey());
            return true;
        }/*w  w  w .java 2s. c  om*/
    }
    return false;
}

From source file:com.gst.infrastructure.security.data.PlatformRequestLog.java

public static PlatformRequestLog from(final StopWatch task, final HttpServletRequest request)
        throws IOException {
    final String requestUrl = request.getRequestURL().toString();

    final Map<String, String[]> parameters = new HashMap<>(request.getParameterMap());
    parameters.remove("password");
    parameters.remove("_");

    return new PlatformRequestLog(task.getStartTime(), task.getTime(), request.getMethod(), requestUrl,
            parameters);//from   w w  w.ja v a  2s .c  o  m
}

From source file:fm.pattern.valex.config.ValexConfiguration.java

public static Map<String, String> getProperties(String key) {
    Map<String, String> map = getConfiguration().getProperties(key);
    if (map == null) {
        return new HashMap<String, String>();
    }//from  w  w w. j  a  v  a  2  s.c  o  m

    Map<String, String> properties = new HashMap<String, String>(map);
    properties.remove("exception");
    return properties;
}

From source file:com.sf.ddao.factory.param.ThreadLocalParameter.java

public static Object remove(String key) {
    Map<String, Object> dataMap = data.get();
    if (dataMap == null) {
        return null;
    }//w  w  w . ja v  a2 s.  com
    return dataMap.remove(key);
}

From source file:asia.gkc.vneedu.utils.FilterUtil.java

public static Map<String, Object> exclude(List<String> list, Map<String, Object> object) {
    list.parallelStream().forEach((e) -> object.remove(e.trim()));
    return object;
}

From source file:Main.java

public static <Key> void removeFromMapThatKeyNotExistInList(Map<Key, ?> map, List<Key> list) {
    Object[] keys = map.keySet().toArray();
    for (Object key : keys) {
        if (!list.contains(key)) {
            map.remove(key);
        }//from   w w w . ja v  a 2s .c om
    }
}