Here you can find the source of emptyToNull(List
public static <T> List<T> emptyToNull(List<T> list)
//package com.java2s; /*// ww w . ja v a2 s .c o m * Copyright (c) 2016 European Spallation Source * Copyright (c) 2016 Cosylab d.d. * * This file is part of Cable Database. * Cable Database is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 2 of the License, or any newer version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see https://www.gnu.org/licenses/gpl-2.0.txt */ import java.util.List; public class Main { public static <T> List<T> emptyToNull(List<T> list) { return list == null ? null : (list.isEmpty() ? null : list); } }