All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cloudfoundry.client.lib.domain.ImmutableCloudServiceBinding Maven / Gradle / Ivy

The newest version!
package org.cloudfoundry.client.lib.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 java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import org.cloudfoundry.client.lib.domain.annotation.Nullable;
import org.cloudfoundry.client.v3.Metadata;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link CloudServiceBinding}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableCloudServiceBinding.builder()}. */ @Generated(from = "CloudServiceBinding", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableCloudServiceBinding extends CloudServiceBinding { private final @Nullable String name; private final @Nullable CloudMetadata metadata; private final @Nullable Metadata v3Metadata; private final UUID applicationGuid; private final @Nullable Map bindingOptions; private final @Nullable Map credentials; private final @Nullable String syslogDrainUrl; private ImmutableCloudServiceBinding( @Nullable String name, @Nullable CloudMetadata metadata, @Nullable Metadata v3Metadata, UUID applicationGuid, @Nullable Map bindingOptions, @Nullable Map credentials, @Nullable String syslogDrainUrl) { this.name = name; this.metadata = metadata; this.v3Metadata = v3Metadata; this.applicationGuid = applicationGuid; this.bindingOptions = bindingOptions; this.credentials = credentials; this.syslogDrainUrl = syslogDrainUrl; } /** * @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 applicationGuid} attribute */ @JsonProperty("applicationGuid") @Override public UUID getApplicationGuid() { return applicationGuid; } /** * @return The value of the {@code bindingOptions} attribute */ @JsonProperty("bindingOptions") @Override public @Nullable Map getBindingOptions() { return bindingOptions; } /** * @return The value of the {@code credentials} attribute */ @JsonProperty("credentials") @Override public @Nullable Map getCredentials() { return credentials; } /** * @return The value of the {@code syslogDrainUrl} attribute */ @JsonProperty("syslogDrainUrl") @Override public @Nullable String getSyslogDrainUrl() { return syslogDrainUrl; } /** * Copy the current immutable object by setting a value for the {@link CloudServiceBinding#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 ImmutableCloudServiceBinding withName(@Nullable String value) { if (Objects.equals(this.name, value)) return this; return new ImmutableCloudServiceBinding( value, this.metadata, this.v3Metadata, this.applicationGuid, this.bindingOptions, this.credentials, this.syslogDrainUrl); } /** * Copy the current immutable object by setting a value for the {@link CloudServiceBinding#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 ImmutableCloudServiceBinding withMetadata(@Nullable CloudMetadata value) { if (this.metadata == value) return this; return new ImmutableCloudServiceBinding( this.name, value, this.v3Metadata, this.applicationGuid, this.bindingOptions, this.credentials, this.syslogDrainUrl); } /** * Copy the current immutable object by setting a value for the {@link CloudServiceBinding#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 ImmutableCloudServiceBinding withV3Metadata(@Nullable Metadata value) { if (this.v3Metadata == value) return this; return new ImmutableCloudServiceBinding( this.name, this.metadata, value, this.applicationGuid, this.bindingOptions, this.credentials, this.syslogDrainUrl); } /** * Copy the current immutable object by setting a value for the {@link CloudServiceBinding#getApplicationGuid() applicationGuid} 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 applicationGuid * @return A modified copy of the {@code this} object */ public final ImmutableCloudServiceBinding withApplicationGuid(UUID value) { if (this.applicationGuid == value) return this; UUID newValue = Objects.requireNonNull(value, "applicationGuid"); return new ImmutableCloudServiceBinding( this.name, this.metadata, this.v3Metadata, newValue, this.bindingOptions, this.credentials, this.syslogDrainUrl); } /** * Copy the current immutable object by replacing the {@link CloudServiceBinding#getBindingOptions() bindingOptions} 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 bindingOptions map * @return A modified copy of {@code this} object */ public final ImmutableCloudServiceBinding withBindingOptions(@Nullable Map entries) { if (this.bindingOptions == entries) return this; @Nullable Map newValue = entries == null ? null : createUnmodifiableMap(true, false, entries); return new ImmutableCloudServiceBinding( this.name, this.metadata, this.v3Metadata, this.applicationGuid, newValue, this.credentials, this.syslogDrainUrl); } /** * Copy the current immutable object by replacing the {@link CloudServiceBinding#getCredentials() credentials} 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 credentials map * @return A modified copy of {@code this} object */ public final ImmutableCloudServiceBinding withCredentials(@Nullable Map entries) { if (this.credentials == entries) return this; @Nullable Map newValue = entries == null ? null : createUnmodifiableMap(true, false, entries); return new ImmutableCloudServiceBinding( this.name, this.metadata, this.v3Metadata, this.applicationGuid, this.bindingOptions, newValue, this.syslogDrainUrl); } /** * Copy the current immutable object by setting a value for the {@link CloudServiceBinding#getSyslogDrainUrl() syslogDrainUrl} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for syslogDrainUrl (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableCloudServiceBinding withSyslogDrainUrl(@Nullable String value) { if (Objects.equals(this.syslogDrainUrl, value)) return this; return new ImmutableCloudServiceBinding( this.name, this.metadata, this.v3Metadata, this.applicationGuid, this.bindingOptions, this.credentials, value); } /** * This instance is equal to all instances of {@code ImmutableCloudServiceBinding} 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 ImmutableCloudServiceBinding && equalTo((ImmutableCloudServiceBinding) another); } private boolean equalTo(ImmutableCloudServiceBinding another) { return Objects.equals(name, another.name) && Objects.equals(metadata, another.metadata) && Objects.equals(v3Metadata, another.v3Metadata) && applicationGuid.equals(another.applicationGuid) && Objects.equals(bindingOptions, another.bindingOptions) && Objects.equals(credentials, another.credentials) && Objects.equals(syslogDrainUrl, another.syslogDrainUrl); } /** * Computes a hash code from attributes: {@code name}, {@code metadata}, {@code v3Metadata}, {@code applicationGuid}, {@code bindingOptions}, {@code credentials}, {@code syslogDrainUrl}. * @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) + applicationGuid.hashCode(); h += (h << 5) + Objects.hashCode(bindingOptions); h += (h << 5) + Objects.hashCode(credentials); h += (h << 5) + Objects.hashCode(syslogDrainUrl); return h; } /** * Prints the immutable value {@code CloudServiceBinding} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "CloudServiceBinding{" + "name=" + name + ", metadata=" + metadata + ", v3Metadata=" + v3Metadata + ", applicationGuid=" + applicationGuid + ", bindingOptions=" + bindingOptions + ", credentials=" + credentials + ", syslogDrainUrl=" + syslogDrainUrl + "}"; } /** * 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 = "CloudServiceBinding", generator = "Immutables") @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json extends CloudServiceBinding { String name; CloudMetadata metadata; Metadata v3Metadata; UUID applicationGuid; Map bindingOptions = null; Map credentials = null; String syslogDrainUrl; @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("applicationGuid") public void setApplicationGuid(UUID applicationGuid) { this.applicationGuid = applicationGuid; } @JsonProperty("bindingOptions") public void setBindingOptions(@Nullable Map bindingOptions) { this.bindingOptions = bindingOptions; } @JsonProperty("credentials") public void setCredentials(@Nullable Map credentials) { this.credentials = credentials; } @JsonProperty("syslogDrainUrl") public void setSyslogDrainUrl(@Nullable String syslogDrainUrl) { this.syslogDrainUrl = syslogDrainUrl; } @Override public String getName() { throw new UnsupportedOperationException(); } @Override public CloudMetadata getMetadata() { throw new UnsupportedOperationException(); } @Override public Metadata getV3Metadata() { throw new UnsupportedOperationException(); } @Override public UUID getApplicationGuid() { throw new UnsupportedOperationException(); } @Override public Map getBindingOptions() { throw new UnsupportedOperationException(); } @Override public Map getCredentials() { throw new UnsupportedOperationException(); } @Override public String getSyslogDrainUrl() { 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 ImmutableCloudServiceBinding fromJson(Json json) { ImmutableCloudServiceBinding.Builder builder = ImmutableCloudServiceBinding.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.applicationGuid != null) { builder.applicationGuid(json.applicationGuid); } if (json.bindingOptions != null) { builder.putAllBindingOptions(json.bindingOptions); } if (json.credentials != null) { builder.putAllCredentials(json.credentials); } if (json.syslogDrainUrl != null) { builder.syslogDrainUrl(json.syslogDrainUrl); } return builder.build(); } /** * Creates an immutable copy of a {@link CloudServiceBinding} 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 CloudServiceBinding instance */ public static ImmutableCloudServiceBinding copyOf(CloudServiceBinding instance) { if (instance instanceof ImmutableCloudServiceBinding) { return (ImmutableCloudServiceBinding) instance; } return ImmutableCloudServiceBinding.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableCloudServiceBinding ImmutableCloudServiceBinding}. *

   * ImmutableCloudServiceBinding.builder()
   *    .name(String | null) // nullable {@link CloudServiceBinding#getName() name}
   *    .metadata(org.cloudfoundry.client.lib.domain.CloudMetadata | null) // nullable {@link CloudServiceBinding#getMetadata() metadata}
   *    .v3Metadata(org.cloudfoundry.client.v3.Metadata | null) // nullable {@link CloudServiceBinding#getV3Metadata() v3Metadata}
   *    .applicationGuid(UUID) // required {@link CloudServiceBinding#getApplicationGuid() applicationGuid}
   *    .bindingOptions(Map&lt;String, Object&gt; | null) // nullable {@link CloudServiceBinding#getBindingOptions() bindingOptions}
   *    .credentials(Map&lt;String, Object&gt; | null) // nullable {@link CloudServiceBinding#getCredentials() credentials}
   *    .syslogDrainUrl(String | null) // nullable {@link CloudServiceBinding#getSyslogDrainUrl() syslogDrainUrl}
   *    .build();
   * 
* @return A new ImmutableCloudServiceBinding builder */ public static ImmutableCloudServiceBinding.Builder builder() { return new ImmutableCloudServiceBinding.Builder(); } /** * Builds instances of type {@link ImmutableCloudServiceBinding ImmutableCloudServiceBinding}. * 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 = "CloudServiceBinding", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_APPLICATION_GUID = 0x1L; private long initBits = 0x1L; private String name; private CloudMetadata metadata; private Metadata v3Metadata; private UUID applicationGuid; private Map bindingOptions = null; private Map credentials = null; private String syslogDrainUrl; private Builder() { } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.client.lib.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((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.client.lib.domain.CloudServiceBinding} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(CloudServiceBinding instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { if (object instanceof CloudEntity) { CloudEntity instance = (CloudEntity) object; @Nullable String nameValue = instance.getName(); if (nameValue != null) { name(nameValue); } @Nullable Metadata v3MetadataValue = instance.getV3Metadata(); if (v3MetadataValue != null) { v3Metadata(v3MetadataValue); } @Nullable CloudMetadata metadataValue = instance.getMetadata(); if (metadataValue != null) { metadata(metadataValue); } } if (object instanceof CloudServiceBinding) { CloudServiceBinding instance = (CloudServiceBinding) object; applicationGuid(instance.getApplicationGuid()); @Nullable Map credentialsValue = instance.getCredentials(); if (credentialsValue != null) { putAllCredentials(credentialsValue); } @Nullable Map bindingOptionsValue = instance.getBindingOptions(); if (bindingOptionsValue != null) { putAllBindingOptions(bindingOptionsValue); } @Nullable String syslogDrainUrlValue = instance.getSyslogDrainUrl(); if (syslogDrainUrlValue != null) { syslogDrainUrl(syslogDrainUrlValue); } } } /** * Initializes the value for the {@link CloudServiceBinding#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 CloudServiceBinding#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 CloudServiceBinding#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 CloudServiceBinding#getApplicationGuid() applicationGuid} attribute. * @param applicationGuid The value for applicationGuid * @return {@code this} builder for use in a chained invocation */ @JsonProperty("applicationGuid") public final Builder applicationGuid(UUID applicationGuid) { this.applicationGuid = Objects.requireNonNull(applicationGuid, "applicationGuid"); initBits &= ~INIT_BIT_APPLICATION_GUID; return this; } /** * Put one entry to the {@link CloudServiceBinding#getBindingOptions() bindingOptions} map. * @param key The key in the bindingOptions map * @param value The associated value in the bindingOptions map * @return {@code this} builder for use in a chained invocation */ public final Builder putBindingOption(String key, Object value) { if (this.bindingOptions == null) { this.bindingOptions = new LinkedHashMap(); } this.bindingOptions.put( Objects.requireNonNull(key, "bindingOptions key"), Objects.requireNonNull(value, "bindingOptions value")); return this; } /** * Put one entry to the {@link CloudServiceBinding#getBindingOptions() bindingOptions} 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 putBindingOption(Map.Entry entry) { if (this.bindingOptions == null) { this.bindingOptions = new LinkedHashMap(); } String k = entry.getKey(); Object v = entry.getValue(); this.bindingOptions.put( Objects.requireNonNull(k, "bindingOptions key"), Objects.requireNonNull(v, "bindingOptions value")); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link CloudServiceBinding#getBindingOptions() bindingOptions} 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 bindingOptions map * @return {@code this} builder for use in a chained invocation */ @JsonProperty("bindingOptions") public final Builder bindingOptions(@Nullable Map entries) { if (entries == null) { this.bindingOptions = null; return this; } this.bindingOptions = new LinkedHashMap(); return putAllBindingOptions(entries); } /** * Put all mappings from the specified map as entries to {@link CloudServiceBinding#getBindingOptions() bindingOptions} map. Nulls are not permitted * @param entries The entries that will be added to the bindingOptions map * @return {@code this} builder for use in a chained invocation */ public final Builder putAllBindingOptions(Map entries) { if (this.bindingOptions == null) { this.bindingOptions = new LinkedHashMap(); } for (Map.Entry e : entries.entrySet()) { String k = e.getKey(); Object v = e.getValue(); this.bindingOptions.put( Objects.requireNonNull(k, "bindingOptions key"), Objects.requireNonNull(v, "bindingOptions value")); } return this; } /** * Put one entry to the {@link CloudServiceBinding#getCredentials() credentials} map. * @param key The key in the credentials map * @param value The associated value in the credentials map * @return {@code this} builder for use in a chained invocation */ public final Builder putCredential(String key, Object value) { if (this.credentials == null) { this.credentials = new LinkedHashMap(); } this.credentials.put( Objects.requireNonNull(key, "credentials key"), Objects.requireNonNull(value, "credentials value")); return this; } /** * Put one entry to the {@link CloudServiceBinding#getCredentials() credentials} 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 putCredential(Map.Entry entry) { if (this.credentials == null) { this.credentials = new LinkedHashMap(); } String k = entry.getKey(); Object v = entry.getValue(); this.credentials.put( Objects.requireNonNull(k, "credentials key"), Objects.requireNonNull(v, "credentials value")); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link CloudServiceBinding#getCredentials() credentials} 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 credentials map * @return {@code this} builder for use in a chained invocation */ @JsonProperty("credentials") public final Builder credentials(@Nullable Map entries) { if (entries == null) { this.credentials = null; return this; } this.credentials = new LinkedHashMap(); return putAllCredentials(entries); } /** * Put all mappings from the specified map as entries to {@link CloudServiceBinding#getCredentials() credentials} map. Nulls are not permitted * @param entries The entries that will be added to the credentials map * @return {@code this} builder for use in a chained invocation */ public final Builder putAllCredentials(Map entries) { if (this.credentials == null) { this.credentials = new LinkedHashMap(); } for (Map.Entry e : entries.entrySet()) { String k = e.getKey(); Object v = e.getValue(); this.credentials.put( Objects.requireNonNull(k, "credentials key"), Objects.requireNonNull(v, "credentials value")); } return this; } /** * Initializes the value for the {@link CloudServiceBinding#getSyslogDrainUrl() syslogDrainUrl} attribute. * @param syslogDrainUrl The value for syslogDrainUrl (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("syslogDrainUrl") public final Builder syslogDrainUrl(@Nullable String syslogDrainUrl) { this.syslogDrainUrl = syslogDrainUrl; return this; } /** * Builds a new {@link ImmutableCloudServiceBinding ImmutableCloudServiceBinding}. * @return An immutable instance of CloudServiceBinding * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableCloudServiceBinding build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableCloudServiceBinding( name, metadata, v3Metadata, applicationGuid, bindingOptions == null ? null : createUnmodifiableMap(false, false, bindingOptions), credentials == null ? null : createUnmodifiableMap(false, false, credentials), syslogDrainUrl); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_APPLICATION_GUID) != 0) attributes.add("applicationGuid"); return "Cannot build CloudServiceBinding, some of required attributes are not set " + attributes; } } private static Map createUnmodifiableMap(boolean checkNulls, boolean skipNulls, Map map) { switch (map.size()) { case 0: return Collections.emptyMap(); case 1: { Map.Entry e = map.entrySet().iterator().next(); K k = e.getKey(); V v = e.getValue(); if (checkNulls) { Objects.requireNonNull(k, "key"); Objects.requireNonNull(v, "value"); } if (skipNulls && (k == null || v == null)) { return Collections.emptyMap(); } return Collections.singletonMap(k, v); } default: { Map linkedMap = new LinkedHashMap<>(map.size()); if (skipNulls || checkNulls) { for (Map.Entry 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, "value"); } linkedMap.put(k, v); } } else { linkedMap.putAll(map); } return Collections.unmodifiableMap(linkedMap); } } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy