@Test public void exandHeaders_AnyGiven_ShouldReturnImmutableList() { assertThrows(UnsupportedOperationException.class, () -> expandHeaders(ImmutableMap.of("k", "v0")).get("k").add("v1")); }
public static Map<String, List<String>> expandHeaders(Map<String, String> headers) { return headers.entrySet().stream() .filter(h -> h.getKey() != null) .filter(h -> h.getValue() != null) .collect(Collectors.collectingAndThen( Collectors.toMap( Map.Entry::getKey, HeaderUtils::expandHeaders), Collections::unmodifiableMap)); }
HeaderUtils { public static Map<String, List<String>> expandHeaders(Map<String, String> headers) { return headers.entrySet().stream() .filter(h -> h.getKey() != null) .filter(h -> h.getValue() != null) .collect(Collectors.collectingAndThen( Collectors.toMap( Map.Entry::getKey, HeaderUtils::expandHeaders), Collections::unmodifiableMap)); } }
HeaderUtils { public static Map<String, List<String>> expandHeaders(Map<String, String> headers) { return headers.entrySet().stream() .filter(h -> h.getKey() != null) .filter(h -> h.getValue() != null) .collect(Collectors.collectingAndThen( Collectors.toMap( Map.Entry::getKey, HeaderUtils::expandHeaders), Collections::unmodifiableMap)); } private  HeaderUtils(); }
HeaderUtils { public static Map<String, List<String>> expandHeaders(Map<String, String> headers) { return headers.entrySet().stream() .filter(h -> h.getKey() != null) .filter(h -> h.getValue() != null) .collect(Collectors.collectingAndThen( Collectors.toMap( Map.Entry::getKey, HeaderUtils::expandHeaders), Collections::unmodifiableMap)); } private  HeaderUtils(); static Map<String, String> flattenHeaders(Map<String, List<String>> headers); static Map<String, String> flattenHeaders(Map<String, List<String>> headers,
			Predicate<String> headerNameFilter); static Map<String, List<String>> expandHeaders(Map<String, String> headers); }
HeaderUtils { public static Map<String, List<String>> expandHeaders(Map<String, String> headers) { return headers.entrySet().stream() .filter(h -> h.getKey() != null) .filter(h -> h.getValue() != null) .collect(Collectors.collectingAndThen( Collectors.toMap( Map.Entry::getKey, HeaderUtils::expandHeaders), Collections::unmodifiableMap)); } private  HeaderUtils(); static Map<String, String> flattenHeaders(Map<String, List<String>> headers); static Map<String, String> flattenHeaders(Map<String, List<String>> headers,
			Predicate<String> headerNameFilter); static Map<String, List<String>> expandHeaders(Map<String, String> headers);  }