Here you can find the source of removeValue(Map
static void removeValue(Map<String, Object> subject, String property, Map<String, Object> value, boolean propertyIsArray)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; import java.util.Map; public class Main { /**/*from ww w .j a v a2 s .co m*/ * Removes a value from a subject. * * @param subject * the subject. * @param property * the property that relates the value to the subject. * @param value * the value to remove. * @param [options] the options to use: [propertyIsArray] true if the * property is always an array, false if not (default: false). */ static void removeValue(Map<String, Object> subject, String property, Map<String, Object> value) { removeValue(subject, property, value, false); } static void removeValue(Map<String, Object> subject, String property, Map<String, Object> value, boolean propertyIsArray) { // filter out value final List<Object> values = new ArrayList<Object>(); if (subject.get(property) instanceof List) { for (final Object e : ((List) subject.get(property))) { if (!(value.equals(e))) { values.add(value); } } } else { if (!value.equals(subject.get(property))) { values.add(subject.get(property)); } } if (values.size() == 0) { subject.remove(property); } else if (values.size() == 1 && !propertyIsArray) { subject.put(property, values.get(0)); } else { subject.put(property, values); } } }