/** * 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(); }
/** * @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(); }