Java Collection First firstOrThat(Collection collection, T that)

Here you can find the source of firstOrThat(Collection collection, T that)

Description

first Or That

License

Open Source License

Declaration

public static <T> T firstOrThat(Collection<T> collection, T that) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {

    public static <T> T firstOrThat(Collection<T> collection, T that) {
        if (collection == null || collection.size() == 0) {
            return that;
        }/*  w  w  w.j a  v a2s. c  o  m*/
        return collection.iterator().next();
    }
}

Related

  1. firstElementOf(final Collection items)
  2. firstFrom(Collection collection)
  3. firstFrom(Collection coll)
  4. firstNonEmpty(Collection... collections)
  5. firstNonNull(Collection collection)
  6. firstValue(Class type, Collection values)
  7. GET_FIRST_ELEMENT(Collection coll)
  8. getCollectionFirstElement( final Collection collection)
  9. getFirst(Collection c)