/** * Copy the current immutable object by setting a value for the {@link Module#usageIndex() usageIndex} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for usageIndex * @return A modified copy of the {@code this} object */ public final ImmutableModule withUsageIndex(UsageIndex value) { if (this.usageIndex == value) return this; UsageIndex newValue = Preconditions.checkNotNull(value, "usageIndex"); return new ImmutableModule(this.name, this.protos, this.output, this.options, newValue); }
/** * This instance is equal to all instances of {@code ImmutableModule} 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 ImmutableModule && equalTo((ImmutableModule) another); }
/** * Creates an immutable copy of a {@link Module} 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 Module instance */ public static ImmutableModule copyOf(Module instance) { if (instance instanceof ImmutableModule) { return (ImmutableModule) instance; } return ImmutableModule.builder() .from(instance) .build(); }
importedFiles.put(path, proto); ImmutableModule.Builder builder = ImmutableModule.builder(); builder.name(configuration.getName()); builder.output(configuration.getOutput());
importedFiles.put(path, proto); ImmutableModule.Builder builder = ImmutableModule.builder(); builder.name(configuration.getName()); builder.output(configuration.getOutput());
/** * Copy the current immutable object by replacing the {@link Module#getOptions() options} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the options map * @return A modified copy of {@code this} object */ public final ImmutableModule withOptions(Map<String, ? extends Object> entries) { if (this.options == entries) return this; ImmutableMap<String, Object> newValue = ImmutableMap.copyOf(entries); return new ImmutableModule(this.name, this.protos, this.output, newValue, this.usageIndex); }
/** * Copy the current immutable object with elements that replace the content of {@link Module#getProtos() protos}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableModule withProtos(Proto... elements) { ImmutableList<Proto> newValue = ImmutableList.copyOf(elements); return new ImmutableModule(this.name, newValue, this.output, this.options, this.usageIndex); }
/** * Copy the current immutable object with elements that replace the content of {@link Module#getProtos() protos}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of protos elements to set * @return A modified copy of {@code this} object */ public final ImmutableModule withProtos(Iterable<? extends Proto> elements) { if (this.protos == elements) return this; ImmutableList<Proto> newValue = ImmutableList.copyOf(elements); return new ImmutableModule(this.name, newValue, this.output, this.options, this.usageIndex); }
/** * Copy the current immutable object by setting a value for the {@link Module#getOutput() output} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for output * @return A modified copy of the {@code this} object */ public final ImmutableModule withOutput(String value) { if (this.output.equals(value)) return this; String newValue = Preconditions.checkNotNull(value, "output"); return new ImmutableModule(this.name, this.protos, newValue, this.options, this.usageIndex); }
/** * Copy the current immutable object by setting a value for the {@link Module#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 ImmutableModule withName(String value) { if (this.name.equals(value)) return this; String newValue = Preconditions.checkNotNull(value, "name"); return new ImmutableModule(newValue, this.protos, this.output, this.options, this.usageIndex); }
/** * Builds a new {@link ImmutableModule ImmutableModule}. * @return An immutable instance of Module * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableModule build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableModule(name, protos.build(), output, options.build(), usageIndex); }