Java List Create getOrCreateList(Map> map, K key)

Here you can find the source of getOrCreateList(Map> map, K key)

Description

get Or Create List

License

Apache License

Declaration

public static <K, T> List<T> getOrCreateList(Map<K, List<T>> map, K key) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static <K, T> List<T> getOrCreateList(Map<K, List<T>> map, K key) {
        List<T> set = map.get(key);
        if (set == null) {
            set = new ArrayList<T>();
            map.put(key, set);/*from w ww.  j  a  v  a2  s .  c o m*/
        }
        return set;
    }
}

Related

  1. createUnmodifiableList(Collection coll)
  2. createUpdateMeasurementItemList(final String itemList, final String updateItem)
  3. createValues(int barCount, String valueDigits, int distributionType, List valueCounts)
  4. createWhereInClause(String field, List values, boolean isString)
  5. createWidList(int[][] widArray)