/** * Copy the current immutable object by setting a value for the {@link Javascript#getName() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final ImmutableJavascript withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableJavascript(this.content, newValue, this.description); }
/** * Copy the current immutable object by setting a value for the {@link Javascript#getContent() content} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for content * @return A modified copy of the {@code this} object */ public final ImmutableJavascript withContent(String value) { if (this.content.equals(value)) return this; String newValue = Objects.requireNonNull(value, "content"); return new ImmutableJavascript(newValue, this.name, this.description); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link Javascript#getDescription() description} attribute. * @param value The value for description * @return A modified copy of {@code this} object */ public final ImmutableJavascript withDescription(String value) { @Nullable String newValue = Objects.requireNonNull(value, "description"); if (Objects.equals(this.description, newValue)) return this; return new ImmutableJavascript(this.content, this.name, newValue); }
/** * Copy the current immutable object by setting an optional value for the {@link Javascript#getDescription() description} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for description * @return A modified copy of {@code this} object */ public final ImmutableJavascript withDescription(Optional<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return new ImmutableJavascript(this.content, this.name, value); }
/** * Builds a new {@link ImmutableJavascript ImmutableJavascript}. * @return An immutable instance of Javascript * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableJavascript build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableJavascript(content, name, description); }