Checks whether the given item exists in the iterable. This is copied from Guava Collect's Iterables.contains() because Guava Collect is not Android-friendly thus core can't depend on it.
(Iterable<T> iterable, T item)
| 858 | * depend on it. |
| 859 | */ |
| 860 | static <T> boolean iterableContains(Iterable<T> iterable, T item) { |
| 861 | if (iterable instanceof Collection) { |
| 862 | Collection<?> collection = (Collection<?>) iterable; |
| 863 | try { |
| 864 | return collection.contains(item); |
| 865 | } catch (NullPointerException e) { |
| 866 | return false; |
| 867 | } catch (ClassCastException e) { |
| 868 | return false; |
| 869 | } |
| 870 | } |
| 871 | for (T i : iterable) { |
| 872 | if (Objects.equal(i, item)) { |
| 873 | return true; |
| 874 | } |
| 875 | } |
| 876 | return false; |
| 877 | } |
| 878 | |
| 879 | /** |
| 880 | * Percent encode the {@code authority} based on |
no test coverage detected