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:de.alpharogroup.lang.object.MergeObjectExtensions.java

/**
 * Compares the given two objects and gets the changed data.
 *
 * @param sourceOjbect/* ww w.  j a v a  2 s  .  c o m*/
 *            the source ojbect
 * @param objectToCompare
 *            the object to compare
 * @return the changed data
 * @throws IllegalAccessException
 *             the illegal access exception
 * @throws InvocationTargetException
 *             the invocation target exception
 * @throws NoSuchMethodException
 *             the no such method exception
 */
@SuppressWarnings("rawtypes")
public static Map<Object, ChangedAttributeResult> getChangedDataMap(final Object sourceOjbect,
        final Object objectToCompare)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    if (sourceOjbect == null || objectToCompare == null
            || !sourceOjbect.getClass().equals(objectToCompare.getClass())) {
        throw new IllegalArgumentException("Object should not be null and be the same type.");
    }
    final Map beanDescription = BeanUtils.describe(sourceOjbect);
    beanDescription.remove("class");
    final Map clonedBeanDescription = BeanUtils.describe(objectToCompare);
    clonedBeanDescription.remove("class");
    final Map<Object, ChangedAttributeResult> changedData = new HashMap<>();
    for (final Object key : beanDescription.keySet()) {
        final Object sourceAttribute = beanDescription.get(key);
        final Object changedAttribute = clonedBeanDescription.get(key);
        if (CompareObjectExtensions.compareTo(sourceOjbect, objectToCompare, key.toString()) != 0) {
            changedData.put(key, new ChangedAttributeResult(key, sourceAttribute, changedAttribute));
        }
    }
    return changedData;
}

From source file:Main.java

/**
 * Removes all the given keys from the given map.
 *
 * @param <TKey> The type of the keys of the map.
 * @param <TValue> The types of the values of the map.
 * @param target The map to remove the specified keys from.
 * @param keys An iterator providing the keys to be removed.
 * @note In case the target or the keys are not effective, nothing happens.
 *//*ww  w .ja  v a2s  . co m*/
public static <TKey, TValue> void removeAll(final Map<TKey, TValue> target,
        final Iterator<? extends TKey> keys) {
    if (target != null && keys != null) {
        while (keys.hasNext()) {
            target.remove(keys.next());
        }
    }
}

From source file:org.apache.usergrid.android.sdk.utils.JsonUtils.java

public static void setBooleanProperty(Map<String, JsonNode> properties, String name, Boolean value) {
    if (value == null) {
        properties.remove(name);
    } else {//  ww w  . j a v a 2s.  co  m
        properties.put(name, JsonNodeFactory.instance.booleanNode(value));
    }
}

From source file:com.netflix.aegisthus.tools.AegisthusSerializer.java

public static String serialize(Map<String, Object> data) {
    StringBuilder str = new StringBuilder();
    str.append("{");
    insertKey(str, data.remove(KEY));
    str.append("{");
    insertKey(str, "deletedAt");
    str.append(data.remove(DELETEDAT));// ww w. ja v a  2  s  .  c om
    str.append(", ");
    insertKey(str, "columns");
    str.append("[");
    serializeColumns(str, data);
    str.append("]");
    str.append("}}");

    return str.toString();
}

From source file:com.creditcloud.ump.model.ump.utils.MessageUtils.java

public static Map<String, String> getFieldEncryptValuesMap(BaseRequest request) {
    Map<String, String> values = MessageUtils.getFieldValuesMap(request);
    Map<String, String> results = new HashMap<>();
    values.remove("sign");
    try {//ww  w.ja v a  2  s. c  o  m
        ReqData reqData = com.umpay.api.paygate.v40.Mer2Plat_v40.makeReqDataByPost(values);
        for (Object object : reqData.getField().entrySet()) {
            Map.Entry<String, String> entry = (Map.Entry<String, String>) object;
            results.put(entry.getKey(), entry.getValue());
        }
    } catch (ReqDataException ex) {
        // ignore
    }

    return results;
}

From source file:com.microsoft.alm.plugin.idea.common.utils.EventContextHelper.java

public static void setSender(final Map<String, Object> eventContext, final String sender) {
    ArgumentHelper.checkNotNull(eventContext, "eventContext");
    if (sender == null) {
        eventContext.remove(EventContextHelper.CONTEXT_SENDER);
    } else {/*  www. j  ava  2s.  co  m*/
        eventContext.put(EventContextHelper.CONTEXT_SENDER, sender);
    }
}

From source file:com.microsoft.alm.plugin.idea.common.utils.EventContextHelper.java

public static void setProject(final Map<String, Object> eventContext, final Project project) {
    ArgumentHelper.checkNotNull(eventContext, "eventContext");
    if (project == null) {
        eventContext.remove(EventContextHelper.CONTEXT_PROJECT);
    } else {// w  w  w  .j  a  v a  2 s .co m
        eventContext.put(EventContextHelper.CONTEXT_PROJECT, project);
    }
}

From source file:edu.txstate.dmlab.clusteringwiki.eval.ExecutionTimes.java

/**
 * Remove specific timer given its id and key
 * @param key/*from  w  ww .j a  va  2 s  .  co m*/
 */
public static void clearTimer(int id, String key) {
    Map<String, Timer> t = timers.get(id);
    if (t != null)
        t.remove(key);
}

From source file:com.codelanx.codelanxlib.util.Players.java

/**
 * Gets any players within range of a specific player, exclusive of the
 * player themselves.// www.  j av  a  2  s.co m
 *
 * @since 0.0.1
 * @version 0.0.1
 *
 * @param range The range in which to look for players
 * @param origin The {@link Player} representing the center of the circle
 * @return Any players within the radius range of the origin, mapped to
 *         the distance away they are
 */
public static Map<Player, Double> getPlayersInRange(int range, Player origin) {
    Map<Player, Double> back = Players.getPlayersInRange(range, origin.getLocation());
    back.remove(origin);
    return back;
}

From source file:ch.sdi.core.TestUtils.java

/**
 * Removes the given key from the environments collection PropertySourceForTest
 *
 * @param aEnv the environment//from  w w w .ja va2 s.  c o m
 * @param aKey the key
 */
public static void removeFromEnvironment(ConfigurableEnvironment aEnv, String aKey) throws SdiException {
    Map<String, Object> map = ConfigUtils.getOrCreatePropertySource(aEnv, TEST_PROPERTY_SOURCE_NAME);

    myLog.debug("removing property " + aKey + " from the environment");
    map.remove(aKey);
}