Here you can find the source of emptyToNull(final Collection
Parameter | Description |
---|---|
value | the collection to check |
public static <T> Collection<T> emptyToNull(final Collection<T> value)
//package com.java2s; //License from project: Educational Community License import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; public class Main { /**//w w w . ja v a 2s.co m * If the given collection is empty null is returned. * * @param value the collection to check * @return the provided collection or null if the provided collection is empty */ public static <T> Set<T> emptyToNull(final Set<T> value) { return value.isEmpty() ? null : value; } /** * If the given collection is empty null is returned. * * @param value the collection to check * @return the provided collection or null if the provided collection is empty */ public static <T, R> Map<T, R> emptyToNull(final Map<T, R> value) { return value.isEmpty() ? null : value; } /** * If the given collection is empty null is returned. * * @param value the collection to check * @return the provided collection or null if the provided collection is empty */ public static <T> List<T> emptyToNull(final List<T> value) { return value.isEmpty() ? null : value; } /** * If the given collection is empty null is returned. * * @param value the collection to check * @return the provided collection or null if the provided collection is empty */ public static <T> Collection<T> emptyToNull(final Collection<T> value) { return value.isEmpty() ? null : value; } }