Java Collection Empty orEmpty(T collection)

Here you can find the source of orEmpty(T collection)

Description

or Empty

License

Apache License

Declaration

@SuppressWarnings("unchecked")
    public static <V, T extends Collection<V>> Collection<V> orEmpty(T collection) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;
import java.util.Collections;

public class Main {
    @SuppressWarnings("unchecked")
    public static <V, T extends Collection<V>> Collection<V> orEmpty(T collection) {
        return (collection == null ? (Collection<V>) Collections.emptyList() : collection);
    }/*from w  w  w  .  j  ava  2 s .c o  m*/
}

Related

  1. nullOrEmpty(Collection c)
  2. nullOrEmpty(final Collection in)
  3. nullOrEmptyToDefault(final Collection collection, final Collection defaultValue)
  4. nullToEmpty(Collection c)
  5. nullToEmpty(Collection coll)
  6. removeEmptyStrings(Collection data)
  7. safeIsEmpty(Collection collection)