/** * Copy the current immutable object with elements that replace the content of {@link MethodCall#getParameters() parameters}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of parameters elements to set * @return A modified copy of {@code this} object */ public final ImmutableMethodCall withParameters(Iterable<String> elements) { if (this.parameters == elements) return this; ImmutableList<String> newValue = ImmutableList.copyOf(elements); return new ImmutableMethodCall(this.name, newValue); }
/** * Copy the current immutable object with elements that replace the content of {@link MethodCall#getParameters() parameters}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableMethodCall withParameters(String... elements) { ImmutableList<String> newValue = ImmutableList.copyOf(elements); return new ImmutableMethodCall(this.name, newValue); }
/** * Copy the current immutable object by setting a value for the {@link MethodCall#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 ImmutableMethodCall withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableMethodCall(newValue, this.parameters); }
/** * Builds a new {@link ImmutableMethodCall ImmutableMethodCall}. * @return An immutable instance of MethodCall * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableMethodCall build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableMethodCall(name, parameters.build()); }