Here you can find the source of nullToEmpty(Collection coll)
public static <U> Collection<U> nullToEmpty(Collection<U> coll)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2014 Bruno Medeiros and other Contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w ww . j a v a2s .com*/ * Bruno Medeiros - initial implementation *******************************************************************************/ import java.util.Collection; import java.util.Collections; public class Main { /** @return given coll if it's not null, or an empty immutable {@link Collection} otherwise. */ public static <U> Collection<U> nullToEmpty(Collection<U> coll) { return coll == null ? Collections.EMPTY_LIST : coll; } /** @return given coll if it's not null, or an empty immutable {@link Iterable} otherwise. */ public static <E> Iterable<E> nullToEmpty(Iterable<E> coll) { return coll == null ? Collections.EMPTY_LIST : coll; } }