/** * Builds a new {@link ImmutableVariableName ImmutableVariableName}. * @return An immutable instance of VariableName * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableVariableName build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableVariableName(name); }
/** * Fill a builder with attribute values from the provided {@code VariableName} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(VariableName instance) { Objects.requireNonNull(instance, "instance"); name(instance.getName()); return this; }
/** * Creates an immutable copy of a {@link VariableName} 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 VariableName instance */ public static ImmutableVariableName copyOf(VariableName instance) { if (instance instanceof ImmutableVariableName) { return (ImmutableVariableName) instance; } return ImmutableVariableName.builder() .from(instance) .build(); }
/** * Creates a builder for {@link ImmutableVariableName ImmutableVariableName}. * @return A new ImmutableVariableName builder */ public static ImmutableVariableName.Builder builder() { return new ImmutableVariableName.Builder(); }