/** * Copy the current immutable object by setting a value for the {@link Header#getHeaderName() headerName} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for headerName * @return A modified copy of the {@code this} object */ public final ImmutableHeader withHeaderName(String value) { if (this.headerName.equals(value)) return this; String newValue = Objects.requireNonNull(value, "headerName"); return new ImmutableHeader(newValue, this.headerValue); }
/** * Copy the current immutable object by setting a value for the {@link Header#getHeaderValue() headerValue} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for headerValue * @return A modified copy of the {@code this} object */ public final ImmutableHeader withHeaderValue(String value) { if (this.headerValue.equals(value)) return this; String newValue = Objects.requireNonNull(value, "headerValue"); return new ImmutableHeader(this.headerName, newValue); }
/** * Builds a new {@link ImmutableHeader ImmutableHeader}. * @return An immutable instance of Header * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableHeader build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableHeader(headerName, headerValue); }