guava/src/com/google/common/collect/Iterables.java
public static boolean contains(Iterable<?> iterable, @Nullable Object element) {
    if (iterable instanceof Collection) {
      Collection<?> collection = (Collection<?>) iterable;
      return Collections2.safeContains(collection, element);
    }
    return Iterators.contains(iterable.iterator(), element);
  }
public static boolean contains(Iterable<?> iterable, @Nullable Object element) {
    if (iterable instanceof Collection) {
      Collection<?> collection = (Collection<?>) iterable;
      return Collections2.safeContains(collection, element);
    }
    return Iterators.contains(iterable.iterator(), element);
  }
Returns {@code true} if {@code iterable} contains any element {@code o} for which {@code
Objects.equals(o, element)} would return {@code true}. Otherwise returns {@code false}, even in
cases where {@link Collection#contains} might throw {@link NullPointerException} or {@link
ClassCastException}.