
com.sap.cloudfoundry.client.facade.domain.ImmutableCloudServicePlan Maven / Gradle / Ivy
Show all versions of cloudfoundry-client-facade Show documentation
package com.sap.cloudfoundry.client.facade.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.sap.cloudfoundry.client.facade.Nullable;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import org.cloudfoundry.client.v3.Metadata;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link CloudServicePlan}.
*
* Use the builder to create immutable instances:
* {@code ImmutableCloudServicePlan.builder()}.
*/
@Generated(from = "CloudServicePlan", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableCloudServicePlan
extends CloudServicePlan {
private final @Nullable String name;
private final @Nullable CloudMetadata metadata;
private final @Nullable Metadata v3Metadata;
private final @Nullable String description;
private final @Nullable Map extra;
private final @Nullable String uniqueId;
private final @Nullable String serviceOfferingId;
private final @Nullable Boolean isFree;
private final @Nullable Boolean isPublic;
private ImmutableCloudServicePlan(
@Nullable String name,
@Nullable CloudMetadata metadata,
@Nullable Metadata v3Metadata,
@Nullable String description,
@Nullable Map extra,
@Nullable String uniqueId,
@Nullable String serviceOfferingId,
@Nullable Boolean isFree,
@Nullable Boolean isPublic) {
this.name = name;
this.metadata = metadata;
this.v3Metadata = v3Metadata;
this.description = description;
this.extra = extra;
this.uniqueId = uniqueId;
this.serviceOfferingId = serviceOfferingId;
this.isFree = isFree;
this.isPublic = isPublic;
}
/**
* @return The value of the {@code name} attribute
*/
@JsonProperty("name")
@Override
public @Nullable String getName() {
return name;
}
/**
* @return The value of the {@code metadata} attribute
*/
@JsonProperty("metadata")
@Override
public @Nullable CloudMetadata getMetadata() {
return metadata;
}
/**
* @return The value of the {@code v3Metadata} attribute
*/
@JsonProperty("v3Metadata")
@Override
public @Nullable Metadata getV3Metadata() {
return v3Metadata;
}
/**
* @return The value of the {@code description} attribute
*/
@JsonProperty("description")
@Override
public @Nullable String getDescription() {
return description;
}
/**
* @return The value of the {@code extra} attribute
*/
@JsonProperty("extra")
@Override
public @Nullable Map getExtra() {
return extra;
}
/**
* @return The value of the {@code uniqueId} attribute
*/
@JsonProperty("uniqueId")
@Override
public @Nullable String getUniqueId() {
return uniqueId;
}
/**
* @return The value of the {@code serviceOfferingId} attribute
*/
@JsonProperty("serviceOfferingId")
@Override
public @Nullable String getServiceOfferingId() {
return serviceOfferingId;
}
/**
* @return The value of the {@code isFree} attribute
*/
@JsonProperty("isFree")
@Override
public @Nullable Boolean isFree() {
return isFree;
}
/**
* @return The value of the {@code isPublic} attribute
*/
@JsonProperty("isPublic")
@Override
public @Nullable Boolean isPublic() {
return isPublic;
}
/**
* Copy the current immutable object by setting a value for the {@link CloudServicePlan#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 (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudServicePlan withName(@Nullable String value) {
if (Objects.equals(this.name, value)) return this;
return new ImmutableCloudServicePlan(
value,
this.metadata,
this.v3Metadata,
this.description,
this.extra,
this.uniqueId,
this.serviceOfferingId,
this.isFree,
this.isPublic);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudServicePlan#getMetadata() metadata} 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 metadata (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudServicePlan withMetadata(@Nullable CloudMetadata value) {
if (this.metadata == value) return this;
return new ImmutableCloudServicePlan(
this.name,
value,
this.v3Metadata,
this.description,
this.extra,
this.uniqueId,
this.serviceOfferingId,
this.isFree,
this.isPublic);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudServicePlan#getV3Metadata() v3Metadata} 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 v3Metadata (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudServicePlan withV3Metadata(@Nullable Metadata value) {
if (this.v3Metadata == value) return this;
return new ImmutableCloudServicePlan(
this.name,
this.metadata,
value,
this.description,
this.extra,
this.uniqueId,
this.serviceOfferingId,
this.isFree,
this.isPublic);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudServicePlan#getDescription() description} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for description (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudServicePlan withDescription(@Nullable String value) {
if (Objects.equals(this.description, value)) return this;
return new ImmutableCloudServicePlan(
this.name,
this.metadata,
this.v3Metadata,
value,
this.extra,
this.uniqueId,
this.serviceOfferingId,
this.isFree,
this.isPublic);
}
/**
* Copy the current immutable object by replacing the {@link CloudServicePlan#getExtra() extra} 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 extra map
* @return A modified copy of {@code this} object
*/
public final ImmutableCloudServicePlan withExtra(@Nullable Map entries) {
if (this.extra == entries) return this;
@Nullable Map newValue = entries == null ? null : createUnmodifiableMap(true, false, entries);
return new ImmutableCloudServicePlan(
this.name,
this.metadata,
this.v3Metadata,
this.description,
newValue,
this.uniqueId,
this.serviceOfferingId,
this.isFree,
this.isPublic);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudServicePlan#getUniqueId() uniqueId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for uniqueId (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudServicePlan withUniqueId(@Nullable String value) {
if (Objects.equals(this.uniqueId, value)) return this;
return new ImmutableCloudServicePlan(
this.name,
this.metadata,
this.v3Metadata,
this.description,
this.extra,
value,
this.serviceOfferingId,
this.isFree,
this.isPublic);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudServicePlan#getServiceOfferingId() serviceOfferingId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for serviceOfferingId (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudServicePlan withServiceOfferingId(@Nullable String value) {
if (Objects.equals(this.serviceOfferingId, value)) return this;
return new ImmutableCloudServicePlan(
this.name,
this.metadata,
this.v3Metadata,
this.description,
this.extra,
this.uniqueId,
value,
this.isFree,
this.isPublic);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudServicePlan#isFree() isFree} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for isFree (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudServicePlan withIsFree(@Nullable Boolean value) {
if (Objects.equals(this.isFree, value)) return this;
return new ImmutableCloudServicePlan(
this.name,
this.metadata,
this.v3Metadata,
this.description,
this.extra,
this.uniqueId,
this.serviceOfferingId,
value,
this.isPublic);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudServicePlan#isPublic() isPublic} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for isPublic (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudServicePlan withIsPublic(@Nullable Boolean value) {
if (Objects.equals(this.isPublic, value)) return this;
return new ImmutableCloudServicePlan(
this.name,
this.metadata,
this.v3Metadata,
this.description,
this.extra,
this.uniqueId,
this.serviceOfferingId,
this.isFree,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableCloudServicePlan} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(Object another) {
if (this == another) return true;
return another instanceof ImmutableCloudServicePlan
&& equalTo(0, (ImmutableCloudServicePlan) another);
}
private boolean equalTo(int synthetic, ImmutableCloudServicePlan another) {
return Objects.equals(name, another.name)
&& Objects.equals(metadata, another.metadata)
&& Objects.equals(v3Metadata, another.v3Metadata)
&& Objects.equals(description, another.description)
&& Objects.equals(extra, another.extra)
&& Objects.equals(uniqueId, another.uniqueId)
&& Objects.equals(serviceOfferingId, another.serviceOfferingId)
&& Objects.equals(isFree, another.isFree)
&& Objects.equals(isPublic, another.isPublic);
}
/**
* Computes a hash code from attributes: {@code name}, {@code metadata}, {@code v3Metadata}, {@code description}, {@code extra}, {@code uniqueId}, {@code serviceOfferingId}, {@code isFree}, {@code isPublic}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(name);
h += (h << 5) + Objects.hashCode(metadata);
h += (h << 5) + Objects.hashCode(v3Metadata);
h += (h << 5) + Objects.hashCode(description);
h += (h << 5) + Objects.hashCode(extra);
h += (h << 5) + Objects.hashCode(uniqueId);
h += (h << 5) + Objects.hashCode(serviceOfferingId);
h += (h << 5) + Objects.hashCode(isFree);
h += (h << 5) + Objects.hashCode(isPublic);
return h;
}
/**
* Prints the immutable value {@code CloudServicePlan} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "CloudServicePlan{"
+ "name=" + name
+ ", metadata=" + metadata
+ ", v3Metadata=" + v3Metadata
+ ", description=" + description
+ ", extra=" + extra
+ ", uniqueId=" + uniqueId
+ ", serviceOfferingId=" + serviceOfferingId
+ ", isFree=" + isFree
+ ", isPublic=" + isPublic
+ "}";
}
/**
* Utility type used to correctly read immutable object from JSON representation.
* @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure
*/
@Generated(from = "CloudServicePlan", generator = "Immutables")
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json extends CloudServicePlan {
String name;
CloudMetadata metadata;
Metadata v3Metadata;
String description;
Map extra = null;
String uniqueId;
String serviceOfferingId;
Boolean isFree;
Boolean isPublic;
@JsonProperty("name")
public void setName(@Nullable String name) {
this.name = name;
}
@JsonProperty("metadata")
public void setMetadata(@Nullable CloudMetadata metadata) {
this.metadata = metadata;
}
@JsonProperty("v3Metadata")
public void setV3Metadata(@Nullable Metadata v3Metadata) {
this.v3Metadata = v3Metadata;
}
@JsonProperty("description")
public void setDescription(@Nullable String description) {
this.description = description;
}
@JsonProperty("extra")
public void setExtra(@Nullable Map extra) {
this.extra = extra;
}
@JsonProperty("uniqueId")
public void setUniqueId(@Nullable String uniqueId) {
this.uniqueId = uniqueId;
}
@JsonProperty("serviceOfferingId")
public void setServiceOfferingId(@Nullable String serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
@JsonProperty("isFree")
public void setIsFree(@Nullable Boolean isFree) {
this.isFree = isFree;
}
@JsonProperty("isPublic")
public void setIsPublic(@Nullable Boolean isPublic) {
this.isPublic = isPublic;
}
@Override
public String getName() { throw new UnsupportedOperationException(); }
@Override
public CloudMetadata getMetadata() { throw new UnsupportedOperationException(); }
@Override
public Metadata getV3Metadata() { throw new UnsupportedOperationException(); }
@Override
public String getDescription() { throw new UnsupportedOperationException(); }
@Override
public Map getExtra() { throw new UnsupportedOperationException(); }
@Override
public String getUniqueId() { throw new UnsupportedOperationException(); }
@Override
public String getServiceOfferingId() { throw new UnsupportedOperationException(); }
@Override
public Boolean isFree() { throw new UnsupportedOperationException(); }
@Override
public Boolean isPublic() { throw new UnsupportedOperationException(); }
}
/**
* @param json A JSON-bindable data structure
* @return An immutable value type
* @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
static ImmutableCloudServicePlan fromJson(Json json) {
ImmutableCloudServicePlan.Builder builder = ImmutableCloudServicePlan.builder();
if (json.name != null) {
builder.name(json.name);
}
if (json.metadata != null) {
builder.metadata(json.metadata);
}
if (json.v3Metadata != null) {
builder.v3Metadata(json.v3Metadata);
}
if (json.description != null) {
builder.description(json.description);
}
if (json.extra != null) {
builder.putAllExtra(json.extra);
}
if (json.uniqueId != null) {
builder.uniqueId(json.uniqueId);
}
if (json.serviceOfferingId != null) {
builder.serviceOfferingId(json.serviceOfferingId);
}
if (json.isFree != null) {
builder.isFree(json.isFree);
}
if (json.isPublic != null) {
builder.isPublic(json.isPublic);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link CloudServicePlan} 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 CloudServicePlan instance
*/
public static ImmutableCloudServicePlan copyOf(CloudServicePlan instance) {
if (instance instanceof ImmutableCloudServicePlan) {
return (ImmutableCloudServicePlan) instance;
}
return ImmutableCloudServicePlan.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableCloudServicePlan ImmutableCloudServicePlan}.
*
* ImmutableCloudServicePlan.builder()
* .name(String | null) // nullable {@link CloudServicePlan#getName() name}
* .metadata(com.sap.cloudfoundry.client.facade.domain.CloudMetadata | null) // nullable {@link CloudServicePlan#getMetadata() metadata}
* .v3Metadata(org.cloudfoundry.client.v3.Metadata | null) // nullable {@link CloudServicePlan#getV3Metadata() v3Metadata}
* .description(String | null) // nullable {@link CloudServicePlan#getDescription() description}
* .extra(Map<String, Object> | null) // nullable {@link CloudServicePlan#getExtra() extra}
* .uniqueId(String | null) // nullable {@link CloudServicePlan#getUniqueId() uniqueId}
* .serviceOfferingId(String | null) // nullable {@link CloudServicePlan#getServiceOfferingId() serviceOfferingId}
* .isFree(Boolean | null) // nullable {@link CloudServicePlan#isFree() isFree}
* .isPublic(Boolean | null) // nullable {@link CloudServicePlan#isPublic() isPublic}
* .build();
*
* @return A new ImmutableCloudServicePlan builder
*/
public static ImmutableCloudServicePlan.Builder builder() {
return new ImmutableCloudServicePlan.Builder();
}
/**
* Builds instances of type {@link ImmutableCloudServicePlan ImmutableCloudServicePlan}.
* Initialize attributes and then invoke the {@link #build()} method to create an
* immutable instance.
* {@code Builder} is not thread-safe and generally should not be stored in a field or collection,
* but instead used immediately to create instances.
*/
@Generated(from = "CloudServicePlan", generator = "Immutables")
public static final class Builder {
private String name;
private CloudMetadata metadata;
private Metadata v3Metadata;
private String description;
private Map extra = null;
private String uniqueId;
private String serviceOfferingId;
private Boolean isFree;
private Boolean isPublic;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.sap.cloudfoundry.client.facade.domain.CloudEntity} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(CloudEntity instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code com.sap.cloudfoundry.client.facade.domain.CloudServicePlan} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(CloudServicePlan instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
private void from(short _unused, Object object) {
long bits = 0;
if (object instanceof CloudEntity) {
CloudEntity instance = (CloudEntity) object;
if ((bits & 0x2L) == 0) {
@Nullable Metadata v3MetadataValue = instance.getV3Metadata();
if (v3MetadataValue != null) {
v3Metadata(v3MetadataValue);
}
bits |= 0x2L;
}
if ((bits & 0x4L) == 0) {
@Nullable String nameValue = instance.getName();
if (nameValue != null) {
name(nameValue);
}
bits |= 0x4L;
}
if ((bits & 0x1L) == 0) {
@Nullable CloudMetadata metadataValue = instance.getMetadata();
if (metadataValue != null) {
metadata(metadataValue);
}
bits |= 0x1L;
}
}
if (object instanceof CloudServicePlan) {
CloudServicePlan instance = (CloudServicePlan) object;
if ((bits & 0x1L) == 0) {
@Nullable CloudMetadata metadataValue = instance.getMetadata();
if (metadataValue != null) {
metadata(metadataValue);
}
bits |= 0x1L;
}
@Nullable String serviceOfferingIdValue = instance.getServiceOfferingId();
if (serviceOfferingIdValue != null) {
serviceOfferingId(serviceOfferingIdValue);
}
@Nullable Boolean isFreeValue = instance.isFree();
if (isFreeValue != null) {
isFree(isFreeValue);
}
@Nullable Map extraValue = instance.getExtra();
if (extraValue != null) {
putAllExtra(extraValue);
}
if ((bits & 0x2L) == 0) {
@Nullable Metadata v3MetadataValue = instance.getV3Metadata();
if (v3MetadataValue != null) {
v3Metadata(v3MetadataValue);
}
bits |= 0x2L;
}
if ((bits & 0x4L) == 0) {
@Nullable String nameValue = instance.getName();
if (nameValue != null) {
name(nameValue);
}
bits |= 0x4L;
}
@Nullable String descriptionValue = instance.getDescription();
if (descriptionValue != null) {
description(descriptionValue);
}
@Nullable Boolean isPublicValue = instance.isPublic();
if (isPublicValue != null) {
isPublic(isPublicValue);
}
@Nullable String uniqueIdValue = instance.getUniqueId();
if (uniqueIdValue != null) {
uniqueId(uniqueIdValue);
}
}
}
/**
* Initializes the value for the {@link CloudServicePlan#getName() name} attribute.
* @param name The value for name (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("name")
public final Builder name(@Nullable String name) {
this.name = name;
return this;
}
/**
* Initializes the value for the {@link CloudServicePlan#getMetadata() metadata} attribute.
* @param metadata The value for metadata (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("metadata")
public final Builder metadata(@Nullable CloudMetadata metadata) {
this.metadata = metadata;
return this;
}
/**
* Initializes the value for the {@link CloudServicePlan#getV3Metadata() v3Metadata} attribute.
* @param v3Metadata The value for v3Metadata (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("v3Metadata")
public final Builder v3Metadata(@Nullable Metadata v3Metadata) {
this.v3Metadata = v3Metadata;
return this;
}
/**
* Initializes the value for the {@link CloudServicePlan#getDescription() description} attribute.
* @param description The value for description (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("description")
public final Builder description(@Nullable String description) {
this.description = description;
return this;
}
/**
* Put one entry to the {@link CloudServicePlan#getExtra() extra} map.
* @param key The key in the extra map
* @param value The associated value in the extra map
* @return {@code this} builder for use in a chained invocation
*/
public final Builder putExtra(String key, Object value) {
if (this.extra == null) {
this.extra = new LinkedHashMap();
}
this.extra.put(
Objects.requireNonNull(key, "extra key"),
Objects.requireNonNull(value, value == null ? "extra value for key: " + key : null));
return this;
}
/**
* Put one entry to the {@link CloudServicePlan#getExtra() extra} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
public final Builder putExtra(Map.Entry entry) {
if (this.extra == null) {
this.extra = new LinkedHashMap();
}
String k = entry.getKey();
Object v = entry.getValue();
this.extra.put(
Objects.requireNonNull(k, "extra key"),
Objects.requireNonNull(v, v == null ? "extra value for key: " + k : null));
return this;
}
/**
* Sets or replaces all mappings from the specified map as entries for the {@link CloudServicePlan#getExtra() extra} map. Nulls are not permitted as keys or values, but parameter itself can be null
* @param entries The entries that will be added to the extra map
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("extra")
public final Builder extra(@Nullable Map entries) {
if (entries == null) {
this.extra = null;
return this;
}
this.extra = new LinkedHashMap();
return putAllExtra(entries);
}
/**
* Put all mappings from the specified map as entries to {@link CloudServicePlan#getExtra() extra} map. Nulls are not permitted
* @param entries The entries that will be added to the extra map
* @return {@code this} builder for use in a chained invocation
*/
public final Builder putAllExtra(Map entries) {
if (this.extra == null) {
this.extra = new LinkedHashMap();
}
for (Map.Entry e : entries.entrySet()) {
String k = e.getKey();
Object v = e.getValue();
this.extra.put(
Objects.requireNonNull(k, "extra key"),
Objects.requireNonNull(v, v == null ? "extra value for key: " + k : null));
}
return this;
}
/**
* Initializes the value for the {@link CloudServicePlan#getUniqueId() uniqueId} attribute.
* @param uniqueId The value for uniqueId (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("uniqueId")
public final Builder uniqueId(@Nullable String uniqueId) {
this.uniqueId = uniqueId;
return this;
}
/**
* Initializes the value for the {@link CloudServicePlan#getServiceOfferingId() serviceOfferingId} attribute.
* @param serviceOfferingId The value for serviceOfferingId (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("serviceOfferingId")
public final Builder serviceOfferingId(@Nullable String serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
return this;
}
/**
* Initializes the value for the {@link CloudServicePlan#isFree() isFree} attribute.
* @param isFree The value for isFree (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("isFree")
public final Builder isFree(@Nullable Boolean isFree) {
this.isFree = isFree;
return this;
}
/**
* Initializes the value for the {@link CloudServicePlan#isPublic() isPublic} attribute.
* @param isPublic The value for isPublic (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("isPublic")
public final Builder isPublic(@Nullable Boolean isPublic) {
this.isPublic = isPublic;
return this;
}
/**
* Builds a new {@link ImmutableCloudServicePlan ImmutableCloudServicePlan}.
* @return An immutable instance of CloudServicePlan
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableCloudServicePlan build() {
return new ImmutableCloudServicePlan(
name,
metadata,
v3Metadata,
description,
extra == null ? null : createUnmodifiableMap(false, false, extra),
uniqueId,
serviceOfferingId,
isFree,
isPublic);
}
}
private static Map createUnmodifiableMap(boolean checkNulls, boolean skipNulls, Map extends K, ? extends V> map) {
switch (map.size()) {
case 0: return Collections.emptyMap();
case 1: {
Map.Entry extends K, ? extends V> e = map.entrySet().iterator().next();
K k = e.getKey();
V v = e.getValue();
if (checkNulls) {
Objects.requireNonNull(k, "key");
Objects.requireNonNull(v, v == null ? "value for key: " + k : null);
}
if (skipNulls && (k == null || v == null)) {
return Collections.emptyMap();
}
return Collections.singletonMap(k, v);
}
default: {
Map linkedMap = new LinkedHashMap<>(map.size() * 4 / 3 + 1);
if (skipNulls || checkNulls) {
for (Map.Entry extends K, ? extends V> e : map.entrySet()) {
K k = e.getKey();
V v = e.getValue();
if (skipNulls) {
if (k == null || v == null) continue;
} else if (checkNulls) {
Objects.requireNonNull(k, "key");
Objects.requireNonNull(v, v == null ? "value for key: " + k : null);
}
linkedMap.put(k, v);
}
} else {
linkedMap.putAll(map);
}
return Collections.unmodifiableMap(linkedMap);
}
}
}
}