Here you can find the source of createIfNull(List
Parameter | Description |
---|---|
list | a parameter |
public static <T> List<T> createIfNull(List<T> list)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { /**// w w w . jav a 2s. c o m * It is common to want to make sure that a collection you receive is not null. Instead, we'd rather have * an empty list. * * @param list * @return the passed in list if not null, otherwise a new ArrayList of the same type */ public static <T> List<T> createIfNull(List<T> list) { return (list == null) ? new ArrayList<T>() : list; } }