android/guava/src/com/google/common/collect/Iterables.java
public static <T> T getOnlyElement(Iterable<T> iterable) {
    return Iterators.getOnlyElement(iterable.iterator());
  }
public static <T> T getOnlyElement(Iterable<T> iterable) {
    return Iterators.getOnlyElement(iterable.iterator());
  }
Returns the single element contained in {@code iterable}.

<p><b>Java 8 users:</b> the {@code Stream} equivalent to this method is {@code
stream.collect(MoreCollectors.onlyElement())}.

@throws NoSuchElementException if the iterable is empty
@throws IllegalArgumentException if the iterable contains multiple elements