Here you can find the source of firstOrThat(Collection
public static <T> T firstOrThat(Collection<T> collection, T that)
//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(); } }