/** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the <em>Jackson</em>-binding infrastructure */ @Deprecated @JsonCreator static ImmutableConfig fromJson(Json json) { ImmutableConfig.Builder builder = ImmutableConfig.builder(); if (json.datacenter != null) { builder.datacenter(json.datacenter); } if (json.nodeName != null) { builder.nodeName(json.nodeName); } if (json.revision != null) { builder.revision(json.revision); } if (json.server != null) { builder.server(json.server); } if (json.version != null) { builder.version(json.version); } return builder.build(); }
/** * Builds a new {@link ImmutableConfig ImmutableConfig}. * @return An immutable instance of Config * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableConfig build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableConfig(datacenter, nodeName, revision, server, version); }
/** * Fill a builder with attribute values from the provided {@code Config} 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 */ public final Builder from(Config instance) { Preconditions.checkNotNull(instance, "instance"); datacenter(instance.getDatacenter()); nodeName(instance.getNodeName()); revision(instance.getRevision()); server(instance.getServer()); version(instance.getVersion()); return this; }
/** * Creates an immutable copy of a {@link Config} 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 Config instance */ public static ImmutableConfig copyOf(Config instance) { if (instance instanceof ImmutableConfig) { return (ImmutableConfig) instance; } return ImmutableConfig.builder() .from(instance) .build(); }
/** * Creates a builder for {@link ImmutableConfig ImmutableConfig}. * @return A new ImmutableConfig builder */ public static ImmutableConfig.Builder builder() { return new ImmutableConfig.Builder(); }