Java List Null Empty newListWhenNull(List list)

Here you can find the source of newListWhenNull(List list)

Description

new List When Null

License

Open Source License

Parameter

Parameter Description
list a parameter

Return

List

Declaration

public static <T> List<T> newListWhenNull(List<T> list) 

Method Source Code


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

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static <T> List<T> newListWhenNull(List<T> list) {
        if (isEmpty(list)) {
            list = new ArrayList<T>();
        }/*from w ww.  jav a2s.  c om*/
        return list;
    }

    public static <T> boolean isEmpty(List<T> list) {
        return list == null || list.size() == 0;
    }
}

Related

  1. listToItemOrNull(List list)
  2. listWithoutNull(A... elements)
  3. listWithoutNull(final List list)
  4. maskNull(List pTypes)
  5. newListIfNull(List list)
  6. newListWithOneNull()
  7. nullOrEmpty(List s)
  8. nullOrEmptyList(List list)
  9. nullSafeAdd(List list, T elem)