Here you can find the source of trimToNull(T collection)
public static <T extends Collection<?>> T trimToNull(T collection)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static <T extends Collection<?>> T trimToNull(T collection) { return isEmpty(collection) ? null : collection; }/*from w w w . j a va2 s. c om*/ public static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); } }