@Test void canAddNewValue_WhenMultipleIsAllowed() { HttpHeader httpHeader = new HttpHeader("Accept", Collections.singletonList("application/json")); httpHeader.value("text/html"); assertThat(httpHeader).hasValues("application/json", "text/html"); }
public void value(String value) { Assert.isNotEmpty(value, "value is required."); if (!this.multipleValuesAllowed && !this.values.isEmpty()) { throw new IllegalStateException("Header " + this.name + " does not support multiple values. " + "To change this value, please clear() it first."); } this.values.add(value); }
HttpHeader implements Header { public void value(String value) { Assert.isNotEmpty(value, "value is required."); if (!this.multipleValuesAllowed && !this.values.isEmpty()) { throw new IllegalStateException("Header " + this.name + " does not support multiple values. " + "To change this value, please clear() it first."); } this.values.add(value); } }
HttpHeader implements Header { public void value(String value) { Assert.isNotEmpty(value, "value is required."); if (!this.multipleValuesAllowed && !this.values.isEmpty()) { throw new IllegalStateException("Header " + this.name + " does not support multiple values. " + "To change this value, please clear() it first."); } this.values.add(value); } HttpHeader(String name);  HttpHeader(String name, Collection<String> values); }
HttpHeader implements Header { public void value(String value) { Assert.isNotEmpty(value, "value is required."); if (!this.multipleValuesAllowed && !this.values.isEmpty()) { throw new IllegalStateException("Header " + this.name + " does not support multiple values. " + "To change this value, please clear() it first."); } this.values.add(value); } HttpHeader(String name);  HttpHeader(String name, Collection<String> values); void value(String value); void clear(); Collection<String> values(); String name(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
HttpHeader implements Header { public void value(String value) { Assert.isNotEmpty(value, "value is required."); if (!this.multipleValuesAllowed && !this.values.isEmpty()) { throw new IllegalStateException("Header " + this.name + " does not support multiple values. " + "To change this value, please clear() it first."); } this.values.add(value); } HttpHeader(String name);  HttpHeader(String name, Collection<String> values); void value(String value); void clear(); Collection<String> values(); String name(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }