Java List Null Empty emptyToNull(List list)

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

Description

empty To Null

License

Open Source License

Declaration

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

Method Source Code


//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);
    }
}

Related

  1. addNonEmpty(List list, String value)
  2. addNotNull(List list, T t)
  3. countIgnoreNull(List list)
  4. emptyStringList()
  5. emptyToNull(List list)
  6. equalsEmptyEqNull(List list1, List list2)
  7. equalsNullSafe(List list1, List list2)
  8. fillEmptyEntries(Iterable keys, Map> map)
  9. fillNull(final List list, final int numElements)