/** * Sets or replaces all elements for {@link Module#getProtos() protos} list. * @param elements An iterable of protos elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder protos(Iterable<? extends Proto> elements) { this.protos = ImmutableList.builder(); return addAllProtos(elements); }
/** * 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); }
builder.name(configuration.getName()); builder.output(configuration.getOutput()); builder.options(configuration.getOptions()); for (Proto proto : importedFiles.values()) { builder.addProtos(proto); builder.usageIndex(index); ImmutableModule module = builder.build(); for (Proto proto : importedFiles.values()) { proto.setModule(module);
builder.name(configuration.getName()); builder.output(configuration.getOutput()); builder.options(configuration.getOptions()); for (Proto proto : importedFiles.values()) { builder.addProtos(proto); builder.usageIndex(index); ImmutableModule module = builder.build(); for (Proto proto : importedFiles.values()) { proto.setModule(module);
/** * 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(); }
/** * Fill a builder with attribute values from the provided {@code Module} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Module instance) { Preconditions.checkNotNull(instance, "instance"); name(instance.getName()); addAllProtos(instance.getProtos()); output(instance.getOutput()); putAllOptions(instance.getOptions()); usageIndex(instance.usageIndex()); return this; }
/** * Creates a builder for {@link ImmutableModule ImmutableModule}. * @return A new ImmutableModule builder */ public static ImmutableModule.Builder builder() { return new ImmutableModule.Builder(); }