MCPcopy Create free account
hub / github.com/grpc/grpc-java / iterableContains

Method iterableContains

core/src/main/java/io/grpc/internal/GrpcUtil.java:860–877  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

sendHeadersInternalMethod · 0.95

Calls 2

containsMethod · 0.45
equalMethod · 0.45

Tested by

no test coverage detected