/** * 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); }
/** * This instance is equal to all instances of {@code ImmutableMethodCall} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableMethodCall && equalTo((ImmutableMethodCall) another); }
/** * Creates an immutable copy of a {@link MethodCall} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable MethodCall instance */ public static ImmutableMethodCall copyOf(MethodCall instance) { if (instance instanceof ImmutableMethodCall) { return (ImmutableMethodCall) instance; } return ImmutableMethodCall.builder() .from(instance) .build(); }
@Override public List<Element> visitMethodcall(CPP14Parser.MethodcallContext ctx) { String methodName = ctx.Identifier().getText(); ImmutableMethodCall.Builder methodBuilder = ImmutableMethodCall.builder().name(methodName); ParametersVisitor paramsVisitor = new ParametersVisitor(); if (ctx.expressionlist() != null) {
/** * 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()); }