Java Map Merge mergeCompactedValue(Map obj, String key, Object value)

Here you can find the source of mergeCompactedValue(Map obj, String key, Object value)

Description

merge Compacted Value

License

Open Source License

Declaration

static void mergeCompactedValue(Map<String, Object> obj, String key, Object value) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;
import java.util.Map;

public class Main {
    static void mergeCompactedValue(Map<String, Object> obj, String key, Object value) {
        if (obj == null) {
            return;
        }//from   www . j a va  2 s.c  o  m
        final Object prop = obj.get(key);
        if (prop == null) {
            obj.put(key, value);
            return;
        }
        if (!(prop instanceof List)) {
            final List<Object> tmp = new ArrayList<Object>();
            tmp.add(prop);
        }
        if (value instanceof List) {
            ((List<Object>) prop).addAll((List<Object>) value);
        } else {
            ((List<Object>) prop).add(value);
        }
    }
}

Related

  1. merge(Map first, Map second)
  2. merge(Map map1, Map map2)
  3. merge(Map mapPriorityLeast, Map mapPriorityFirst)
  4. mergeAggCompStatsTopoPageSpout(Map accSpoutStats, Map spoutStats)
  5. mergeBootArgumentsIntoMap(String[] args, Map map)
  6. mergeCompositions( Map target, Map source)
  7. mergeConfig(Map userConfig, Map referenceConfig)
  8. mergeCounterMap(Map map, String key, Object value)
  9. mergeCountMaps(Map base, Map other)