### Question:
Utils { public static <T> T getValue(Iterable<T> values, int pos) { if (values instanceof List) { List<T> vs = (List<T>) values; return vs.get(pos); } else { int i = 0; for (T v : values) { if (i == pos) { return v; } ++i; } throw new IndexOutOfBoundsException(pos + " >= " + i); } } private  Utils(); static Id normalize(Id id); static String getTagValue(Id id, String k); static String getTagValue(Iterable<Tag> tags, String k); static T getValue(Iterable<T> values, int pos); static Measurement first(Iterable<Measurement> ms, Tag t); static Measurement first(final Iterable<Measurement> ms, final String k, final String v); static Measurement first(Iterable<Measurement> ms, Predicate<Measurement> p); static Iterable<Measurement> filter(Iterable<Measurement> ms, Tag t); static Iterable<Measurement> filter(
      final Iterable<Measurement> ms, final String k, final String v); static Iterable<Measurement> filter(
      final Iterable<Measurement> ms, final Predicate<Measurement> p); static List<T> toList(Iterable<T> iter); static List<T> toList(Iterator<T> iter); @SuppressWarnings("PMD.UnusedLocalVariable") static int size(Iterable<T> iter); static V computeIfAbsent(ConcurrentMap<K, V> map, K k, Function<K, V> f); static void propagateTypeError(
      Registry registry, Id id, Class<?> desiredClass, Class<?> actualClass);  }### Answer:
@Test public void getValueList() { List<String> vs = new ArrayList<>(); vs.add("a"); vs.add("b"); vs.add("c"); Assertions.assertEquals("a", Utils.getValue(vs, 0)); Assertions.assertEquals("b", Utils.getValue(vs, 1)); Assertions.assertEquals("c", Utils.getValue(vs, 2)); Assertions.assertThrows(IndexOutOfBoundsException.class, () -> Utils.getValue(vs, 3)); Assertions.assertThrows(IndexOutOfBoundsException.class, () -> Utils.getValue(vs, -3)); }
@Test public void getValueIterable() { List<String> vs = new ArrayList<>(); vs.add("a"); vs.add("b"); vs.add("c"); Iterable<String> it = vs::iterator; Assertions.assertEquals("a", Utils.getValue(it, 0)); Assertions.assertEquals("b", Utils.getValue(it, 1)); Assertions.assertEquals("c", Utils.getValue(it, 2)); Assertions.assertThrows(IndexOutOfBoundsException.class, () -> Utils.getValue(it, 3)); Assertions.assertThrows(IndexOutOfBoundsException.class, () -> Utils.getValue(it, -3)); }