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:com.networknt.light.rule.host.AbstractHostRule.java

protected void delHost(Map<String, Object> data) throws Exception {
    Map<String, Object> hostMap = ServiceLocator.getInstance().getHostMap();
    hostMap.remove(data.get("id"));
    writeHostMap(hostMap);// w  ww.j  a  v  a2s .com
}

From source file:com.example.notes.ExceptionSupressingErrorAttributes.java

@Override
public Map<String, Object> getErrorAttributes(RequestAttributes requestAttributes, boolean includeStackTrace) {
    Map<String, Object> errorAttributes = super.getErrorAttributes(requestAttributes, includeStackTrace);
    errorAttributes.remove("exception");
    Object message = requestAttributes.getAttribute("javax.servlet.error.message",
            RequestAttributes.SCOPE_REQUEST);
    if (message != null) {
        errorAttributes.put("message", message);
    }/*from   w w w  . java 2  s  .co  m*/
    return errorAttributes;
}

From source file:com.ikanow.aleph2.analytics.services.DeduplicationService.java

/** The heart of the dedup logic
 *  (everything gets ordered in the correct order except if policy is custom, in which case the ordering is a
 *   bit arbitrary anyway)/*from w  ww . j  av  a  2 s  .  c o  m*/
 * @param policy
 * @param context
 * @param timestamp_field
 * @param new_record
 * @param old_record
 * @param key
 * @param mutable_obj_map
 * @returns a stream of objects to delete efficiently
 */
protected static Stream<JsonNode> handleDuplicateRecord(final DocumentSchemaBean config,
        Optional<Tuple2<IEnrichmentBatchModule, DeduplicationEnrichmentContext>> custom_handler,
        final String timestamp_field, final LinkedList<Tuple3<Long, IBatchRecord, ObjectNode>> new_records,
        final List<JsonNode> old_records, final JsonNode key,
        final Map<JsonNode, LinkedList<Tuple3<Long, IBatchRecord, ObjectNode>>> mutable_obj_map) {
    return Patterns.match(config.deduplication_policy()).<Stream<JsonNode>>andReturn()
            .when(p -> p == DeduplicationPolicy.leave, __ -> {
                mutable_obj_map.remove(key); //(drop new record)
                return Stream.empty();
            }).when(p -> p == DeduplicationPolicy.update, __ -> {
                final Tuple3<Long, IBatchRecord, ObjectNode> last_record = new_records.peekLast();
                final JsonNode old_record = old_records.stream().findFirst().get();
                if (newRecordUpdatesOld(timestamp_field, last_record._2().getJson(), old_record)) {
                    last_record._3().set(AnnotationBean._ID, old_record.get(AnnotationBean._ID));
                    return config.delete_unhandled_duplicates() ? deleteOtherDuplicates(old_records.stream())
                            : Stream.empty();
                } else {
                    mutable_obj_map.remove(key); //(drop new record)            
                    return Stream.empty();
                }
            }).when(p -> p == DeduplicationPolicy.overwrite, __ -> {
                final Tuple3<Long, IBatchRecord, ObjectNode> last_record = new_records.peekLast();
                // Just update the new record's "_id" field
                final JsonNode old_record = old_records.stream().findFirst().get();
                last_record._3().set(AnnotationBean._ID, old_record.get(AnnotationBean._ID));
                return config.delete_unhandled_duplicates() ? deleteOtherDuplicates(old_records.stream())
                        : Stream.empty();
            }).when(p -> p == DeduplicationPolicy.custom_update, __ -> {
                final Tuple3<Long, IBatchRecord, ObjectNode> last_record = new_records.peekLast();
                final JsonNode old_record = old_records.stream().findFirst().get();
                if (newRecordUpdatesOld(timestamp_field, last_record._2().getJson(), old_record)) {
                    mutable_obj_map.remove(key); // (since the "final step" logic is responsible for calling the update code)
                    return handleCustomDeduplication(custom_handler, new_records, old_records, key);
                } else {
                    mutable_obj_map.remove(key); //(drop new record)
                    return Stream.empty();
                }
            }).otherwise(__ -> {
                mutable_obj_map.remove(key); // (since the "final step" logic is responsible for calling the update code)      
                return handleCustomDeduplication(custom_handler, new_records, old_records, key);
            });
}

From source file:org.talend.components.dataprep.connection.DataPrepStreamMapper.java

public Map<String, String> nextRecord() {
    Map<String, String> record = iterator.next();
    record.remove("tdpId");
    LOGGER.trace("Record is : {}", record);
    return record;
}

From source file:org.ow2.proactive.connector.iaas.cache.InfrastructureCache.java

public void deleteInfrastructure(Infrastructure infrastructure) {
    Map<String, Infrastructure> tempInfrastructures = cloneSupportedInfrastructures();

    tempInfrastructures.remove(infrastructure.getId());
    supportedInfrastructures = ImmutableMap.copyOf(tempInfrastructures);
}

From source file:com.liferay.faces.demos.spring.ViewScope.java

public Object remove(String name) {

    FacesContext facesContext = FacesContext.getCurrentInstance();
    Map<String, Object> viewMap = facesContext.getViewRoot().getViewMap();

    return viewMap.remove(name);
}

From source file:org.ow2.proactive.connector.iaas.cache.InstanceCache.java

public void deleteInfrastructure(Infrastructure infrastructure) {
    Map<String, Set<Instance>> tempInstances = cloneCreatedInstances();
    tempInstances.remove(infrastructure.getId());
    createdInstances = ImmutableMap.copyOf(tempInstances);
}

From source file:guru.qas.martini.jmeter.sampler.SamplerContext.java

protected void remove(String key) {
    Map<String, Object> samplerContext = context.getSamplerContext();
    samplerContext.remove(key);
}

From source file:flens.filter.RenameFilter.java

public Collection<Record> process(Record in) {
    Map vals = in.getValues();
    for (Pair ren : this.names) {
        Object val = vals.remove(ren.getKey());
        if (val != null) {
            if (!((String) ren.getRight()).isEmpty())
                vals.put(ren.getRight(), val);
            if (ren.getRight().equals(Constants.TIME)) {

                vals.put(Constants.TIME, in.getTimestamp());
            }/*w  ww .ja  v  a2  s .  com*/
        }
    }

    tag(in);
    return Collections.EMPTY_LIST;
}

From source file:org.ehoffman.aopalliance.extensions.scope.STScope.java

@Override
public Object remove(String name) {
    Map<String, Object> scope = this.threadScope.get();
    return scope.remove(name);
}