Headers { public String getFirst(String key) { return headers .stream() .filter(h -> isName(h, key)) .findFirst() .map(Header::getValue) .orElse(""); } Headers();  Headers(Collection<Entry> entries); void add(String name, String value); void add(String name, Supplier<String> value); void replace(String name, String value); int size(); List<String> get(String name); void putAll(Headers header); boolean containsKey(String name); void clear(); String getFirst(String key); List<Header> all(); @Override String toString(); void cookie(Cookie cookie); void cookie(Collection<Cookie> cookies); @Override boolean equals(Object o); @Override int hashCode();  }
@Test void canCreateHeadersFromACollection() { Headers h = new Headers(asList( new Headers.Entry("Accepts", "application/json"), new Headers.Entry("Content-Type", "application/xml")) ); assertEquals("application/json", h.getFirst("Accepts")); assertEquals("application/xml", h.getFirst("Content-Type")); }