Here you can find the source of nullSafeList(List
Parameter | Description |
---|---|
list | for which we want safe access |
public static <O extends Object> List<O> nullSafeList(List<O> list)
//package com.java2s; //License from project: Apache License import java.util.Collections; import java.util.List; public class Main { /**/*w w w . j a va 2s .co m*/ * Always returns a non-null list - either the argument list or * a new empty list. * * @param list for which we want safe access * @return a non-null list */ public static <O extends Object> List<O> nullSafeList(List<O> list) { return list != null ? list : Collections.<O>emptyList(); } }