CollectionUtils { public static <T> T oneElt(Collection<T> collection) { if ( collection == null || collection.isEmpty() ) return null; if ( collection instanceof List<?> ) return ((List<T>)collection).get(0); return Iter.first(collection.iterator()); }  static boolean sameElts(Collection<T> left, Collection<T> right); static T oneElt(Collection<T> collection);  }
@Test public void oneElt_01() { List<String> x = Arrays.asList("a", "b", "c") ; assertEquals("a", oneElt(x)); }
@Test public void oneElt_02() { List<String> x = Arrays.asList() ; assertNull(oneElt(x)); }