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

com.sap.cloudfoundry.client.facade.dto.ImmutableApplicationToCreateDto Maven / Gradle / Ivy

There is a newer version: 2.56.0
Show newest version
package com.sap.cloudfoundry.client.facade.dto;

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 com.sap.cloudfoundry.client.facade.domain.CloudRoute;
import com.sap.cloudfoundry.client.facade.domain.Staging;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.cloudfoundry.client.v3.Metadata;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableApplicationToCreateDto.builder()}. */ @Generated(from = "ApplicationToCreateDto", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableApplicationToCreateDto implements ApplicationToCreateDto { private final String name; private final @Nullable Staging staging; private final @Nullable Integer diskQuotaInMb; private final @Nullable Integer memoryInMb; private final @Nullable Metadata metadata; private final @Nullable Set routes; private final @Nullable Map env; private ImmutableApplicationToCreateDto( String name, @Nullable Staging staging, @Nullable Integer diskQuotaInMb, @Nullable Integer memoryInMb, @Nullable Metadata metadata, @Nullable Set routes, @Nullable Map env) { this.name = name; this.staging = staging; this.diskQuotaInMb = diskQuotaInMb; this.memoryInMb = memoryInMb; this.metadata = metadata; this.routes = routes; this.env = env; } /** * @return The value of the {@code name} attribute */ @JsonProperty("name") @Override public String getName() { return name; } /** * @return The value of the {@code staging} attribute */ @JsonProperty("staging") @Override public @Nullable Staging getStaging() { return staging; } /** * @return The value of the {@code diskQuotaInMb} attribute */ @JsonProperty("diskQuotaInMb") @Override public @Nullable Integer getDiskQuotaInMb() { return diskQuotaInMb; } /** * @return The value of the {@code memoryInMb} attribute */ @JsonProperty("memoryInMb") @Override public @Nullable Integer getMemoryInMb() { return memoryInMb; } /** * @return The value of the {@code metadata} attribute */ @JsonProperty("metadata") @Override public @Nullable Metadata getMetadata() { return metadata; } /** * @return The value of the {@code routes} attribute */ @JsonProperty("routes") @Override public @Nullable Set getRoutes() { return routes; } /** * @return The value of the {@code env} attribute */ @JsonProperty("env") @Override public @Nullable Map getEnv() { return env; } /** * Copy the current immutable object by setting a value for the {@link ApplicationToCreateDto#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 * @return A modified copy of the {@code this} object */ public final ImmutableApplicationToCreateDto withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new ImmutableApplicationToCreateDto( newValue, this.staging, this.diskQuotaInMb, this.memoryInMb, this.metadata, this.routes, this.env); } /** * Copy the current immutable object by setting a value for the {@link ApplicationToCreateDto#getStaging() staging} 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 staging (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableApplicationToCreateDto withStaging(@Nullable Staging value) { if (this.staging == value) return this; return new ImmutableApplicationToCreateDto(this.name, value, this.diskQuotaInMb, this.memoryInMb, this.metadata, this.routes, this.env); } /** * Copy the current immutable object by setting a value for the {@link ApplicationToCreateDto#getDiskQuotaInMb() diskQuotaInMb} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for diskQuotaInMb (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableApplicationToCreateDto withDiskQuotaInMb(@Nullable Integer value) { if (Objects.equals(this.diskQuotaInMb, value)) return this; return new ImmutableApplicationToCreateDto(this.name, this.staging, value, this.memoryInMb, this.metadata, this.routes, this.env); } /** * Copy the current immutable object by setting a value for the {@link ApplicationToCreateDto#getMemoryInMb() memoryInMb} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for memoryInMb (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableApplicationToCreateDto withMemoryInMb(@Nullable Integer value) { if (Objects.equals(this.memoryInMb, value)) return this; return new ImmutableApplicationToCreateDto(this.name, this.staging, this.diskQuotaInMb, value, this.metadata, this.routes, this.env); } /** * Copy the current immutable object by setting a value for the {@link ApplicationToCreateDto#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 ImmutableApplicationToCreateDto withMetadata(@Nullable Metadata value) { if (this.metadata == value) return this; return new ImmutableApplicationToCreateDto(this.name, this.staging, this.diskQuotaInMb, this.memoryInMb, value, this.routes, this.env); } /** * Copy the current immutable object with elements that replace the content of {@link ApplicationToCreateDto#getRoutes() routes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableApplicationToCreateDto withRoutes(@Nullable CloudRoute... elements) { if (elements == null) { return new ImmutableApplicationToCreateDto(this.name, this.staging, this.diskQuotaInMb, this.memoryInMb, this.metadata, null, this.env); } @Nullable Set newValue = Arrays.asList(elements) == null ? null : createUnmodifiableSet(createSafeList(Arrays.asList(elements), true, false)); return new ImmutableApplicationToCreateDto(this.name, this.staging, this.diskQuotaInMb, this.memoryInMb, this.metadata, newValue, this.env); } /** * Copy the current immutable object with elements that replace the content of {@link ApplicationToCreateDto#getRoutes() routes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of routes elements to set * @return A modified copy of {@code this} object */ public final ImmutableApplicationToCreateDto withRoutes(@Nullable Iterable elements) { if (this.routes == elements) return this; @Nullable Set newValue = elements == null ? null : createUnmodifiableSet(createSafeList(elements, true, false)); return new ImmutableApplicationToCreateDto(this.name, this.staging, this.diskQuotaInMb, this.memoryInMb, this.metadata, newValue, this.env); } /** * Copy the current immutable object by replacing the {@link ApplicationToCreateDto#getEnv() env} 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 env map * @return A modified copy of {@code this} object */ public final ImmutableApplicationToCreateDto withEnv(@Nullable Map entries) { if (this.env == entries) return this; @Nullable Map newValue = entries == null ? null : createUnmodifiableMap(true, false, entries); return new ImmutableApplicationToCreateDto( this.name, this.staging, this.diskQuotaInMb, this.memoryInMb, this.metadata, this.routes, newValue); } /** * This instance is equal to all instances of {@code ImmutableApplicationToCreateDto} 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 ImmutableApplicationToCreateDto && equalTo(0, (ImmutableApplicationToCreateDto) another); } private boolean equalTo(int synthetic, ImmutableApplicationToCreateDto another) { return name.equals(another.name) && Objects.equals(staging, another.staging) && Objects.equals(diskQuotaInMb, another.diskQuotaInMb) && Objects.equals(memoryInMb, another.memoryInMb) && Objects.equals(metadata, another.metadata) && Objects.equals(routes, another.routes) && Objects.equals(env, another.env); } /** * Computes a hash code from attributes: {@code name}, {@code staging}, {@code diskQuotaInMb}, {@code memoryInMb}, {@code metadata}, {@code routes}, {@code env}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + Objects.hashCode(staging); h += (h << 5) + Objects.hashCode(diskQuotaInMb); h += (h << 5) + Objects.hashCode(memoryInMb); h += (h << 5) + Objects.hashCode(metadata); h += (h << 5) + Objects.hashCode(routes); h += (h << 5) + Objects.hashCode(env); return h; } /** * Prints the immutable value {@code ApplicationToCreateDto} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "ApplicationToCreateDto{" + "name=" + name + ", staging=" + staging + ", diskQuotaInMb=" + diskQuotaInMb + ", memoryInMb=" + memoryInMb + ", metadata=" + metadata + ", routes=" + routes + ", env=" + env + "}"; } /** * 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 = "ApplicationToCreateDto", generator = "Immutables") @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ApplicationToCreateDto { String name; Staging staging; Integer diskQuotaInMb; Integer memoryInMb; Metadata metadata; Set routes = null; Map env = null; @JsonProperty("name") public void setName(String name) { this.name = name; } @JsonProperty("staging") public void setStaging(@Nullable Staging staging) { this.staging = staging; } @JsonProperty("diskQuotaInMb") public void setDiskQuotaInMb(@Nullable Integer diskQuotaInMb) { this.diskQuotaInMb = diskQuotaInMb; } @JsonProperty("memoryInMb") public void setMemoryInMb(@Nullable Integer memoryInMb) { this.memoryInMb = memoryInMb; } @JsonProperty("metadata") public void setMetadata(@Nullable Metadata metadata) { this.metadata = metadata; } @JsonProperty("routes") public void setRoutes(@Nullable Set routes) { this.routes = routes; } @JsonProperty("env") public void setEnv(@Nullable Map env) { this.env = env; } @Override public String getName() { throw new UnsupportedOperationException(); } @Override public Staging getStaging() { throw new UnsupportedOperationException(); } @Override public Integer getDiskQuotaInMb() { throw new UnsupportedOperationException(); } @Override public Integer getMemoryInMb() { throw new UnsupportedOperationException(); } @Override public Metadata getMetadata() { throw new UnsupportedOperationException(); } @Override public Set getRoutes() { throw new UnsupportedOperationException(); } @Override public Map getEnv() { 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 ImmutableApplicationToCreateDto fromJson(Json json) { ImmutableApplicationToCreateDto.Builder builder = ImmutableApplicationToCreateDto.builder(); if (json.name != null) { builder.name(json.name); } if (json.staging != null) { builder.staging(json.staging); } if (json.diskQuotaInMb != null) { builder.diskQuotaInMb(json.diskQuotaInMb); } if (json.memoryInMb != null) { builder.memoryInMb(json.memoryInMb); } if (json.metadata != null) { builder.metadata(json.metadata); } if (json.routes != null) { builder.addAllRoutes(json.routes); } if (json.env != null) { builder.putAllEnv(json.env); } return builder.build(); } /** * Creates an immutable copy of a {@link ApplicationToCreateDto} 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 ApplicationToCreateDto instance */ public static ImmutableApplicationToCreateDto copyOf(ApplicationToCreateDto instance) { if (instance instanceof ImmutableApplicationToCreateDto) { return (ImmutableApplicationToCreateDto) instance; } return ImmutableApplicationToCreateDto.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableApplicationToCreateDto ImmutableApplicationToCreateDto}. *

   * ImmutableApplicationToCreateDto.builder()
   *    .name(String) // required {@link ApplicationToCreateDto#getName() name}
   *    .staging(com.sap.cloudfoundry.client.facade.domain.Staging | null) // nullable {@link ApplicationToCreateDto#getStaging() staging}
   *    .diskQuotaInMb(Integer | null) // nullable {@link ApplicationToCreateDto#getDiskQuotaInMb() diskQuotaInMb}
   *    .memoryInMb(Integer | null) // nullable {@link ApplicationToCreateDto#getMemoryInMb() memoryInMb}
   *    .metadata(org.cloudfoundry.client.v3.Metadata | null) // nullable {@link ApplicationToCreateDto#getMetadata() metadata}
   *    .routes(Set&lt;com.sap.cloudfoundry.client.facade.domain.CloudRoute&gt; | null) // nullable {@link ApplicationToCreateDto#getRoutes() routes}
   *    .env(Map&lt;String, String&gt; | null) // nullable {@link ApplicationToCreateDto#getEnv() env}
   *    .build();
   * 
* @return A new ImmutableApplicationToCreateDto builder */ public static ImmutableApplicationToCreateDto.Builder builder() { return new ImmutableApplicationToCreateDto.Builder(); } /** * Builds instances of type {@link ImmutableApplicationToCreateDto ImmutableApplicationToCreateDto}. * 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 = "ApplicationToCreateDto", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_NAME = 0x1L; private long initBits = 0x1L; private String name; private Staging staging; private Integer diskQuotaInMb; private Integer memoryInMb; private Metadata metadata; private List routes = null; private Map env = null; private Builder() { } /** * Fill a builder with attribute values from the provided {@code ApplicationToCreateDto} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ApplicationToCreateDto instance) { Objects.requireNonNull(instance, "instance"); this.name(instance.getName()); @Nullable Staging stagingValue = instance.getStaging(); if (stagingValue != null) { staging(stagingValue); } @Nullable Integer diskQuotaInMbValue = instance.getDiskQuotaInMb(); if (diskQuotaInMbValue != null) { diskQuotaInMb(diskQuotaInMbValue); } @Nullable Integer memoryInMbValue = instance.getMemoryInMb(); if (memoryInMbValue != null) { memoryInMb(memoryInMbValue); } @Nullable Metadata metadataValue = instance.getMetadata(); if (metadataValue != null) { metadata(metadataValue); } @Nullable Set routesValue = instance.getRoutes(); if (routesValue != null) { addAllRoutes(routesValue); } @Nullable Map envValue = instance.getEnv(); if (envValue != null) { putAllEnv(envValue); } return this; } /** * Initializes the value for the {@link ApplicationToCreateDto#getName() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @JsonProperty("name") public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Initializes the value for the {@link ApplicationToCreateDto#getStaging() staging} attribute. * @param staging The value for staging (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("staging") public final Builder staging(@Nullable Staging staging) { this.staging = staging; return this; } /** * Initializes the value for the {@link ApplicationToCreateDto#getDiskQuotaInMb() diskQuotaInMb} attribute. * @param diskQuotaInMb The value for diskQuotaInMb (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("diskQuotaInMb") public final Builder diskQuotaInMb(@Nullable Integer diskQuotaInMb) { this.diskQuotaInMb = diskQuotaInMb; return this; } /** * Initializes the value for the {@link ApplicationToCreateDto#getMemoryInMb() memoryInMb} attribute. * @param memoryInMb The value for memoryInMb (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("memoryInMb") public final Builder memoryInMb(@Nullable Integer memoryInMb) { this.memoryInMb = memoryInMb; return this; } /** * Initializes the value for the {@link ApplicationToCreateDto#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 Metadata metadata) { this.metadata = metadata; return this; } /** * Adds one element to {@link ApplicationToCreateDto#getRoutes() routes} set. * @param element A routes element * @return {@code this} builder for use in a chained invocation */ public final Builder addRoute(CloudRoute element) { if (this.routes == null) { this.routes = new ArrayList(); } this.routes.add(Objects.requireNonNull(element, "routes element")); return this; } /** * Adds elements to {@link ApplicationToCreateDto#getRoutes() routes} set. * @param elements An array of routes elements * @return {@code this} builder for use in a chained invocation */ public final Builder addRoutes(CloudRoute... elements) { if (this.routes == null) { this.routes = new ArrayList(); } for (CloudRoute element : elements) { this.routes.add(Objects.requireNonNull(element, "routes element")); } return this; } /** * Sets or replaces all elements for {@link ApplicationToCreateDto#getRoutes() routes} set. * @param elements An iterable of routes elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("routes") public final Builder routes(@Nullable Iterable elements) { if (elements == null) { this.routes = null; return this; } this.routes = new ArrayList(); return addAllRoutes(elements); } /** * Adds elements to {@link ApplicationToCreateDto#getRoutes() routes} set. * @param elements An iterable of routes elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllRoutes(Iterable elements) { Objects.requireNonNull(elements, "routes element"); if (this.routes == null) { this.routes = new ArrayList(); } for (CloudRoute element : elements) { this.routes.add(Objects.requireNonNull(element, "routes element")); } return this; } /** * Put one entry to the {@link ApplicationToCreateDto#getEnv() env} map. * @param key The key in the env map * @param value The associated value in the env map * @return {@code this} builder for use in a chained invocation */ public final Builder putEnv(String key, String value) { if (this.env == null) { this.env = new LinkedHashMap(); } this.env.put( Objects.requireNonNull(key, "env key"), Objects.requireNonNull(value, value == null ? "env value for key: " + key : null)); return this; } /** * Put one entry to the {@link ApplicationToCreateDto#getEnv() env} 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 putEnv(Map.Entry entry) { if (this.env == null) { this.env = new LinkedHashMap(); } String k = entry.getKey(); String v = entry.getValue(); this.env.put( Objects.requireNonNull(k, "env key"), Objects.requireNonNull(v, v == null ? "env value for key: " + k : null)); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link ApplicationToCreateDto#getEnv() env} 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 env map * @return {@code this} builder for use in a chained invocation */ @JsonProperty("env") public final Builder env(@Nullable Map entries) { if (entries == null) { this.env = null; return this; } this.env = new LinkedHashMap(); return putAllEnv(entries); } /** * Put all mappings from the specified map as entries to {@link ApplicationToCreateDto#getEnv() env} map. Nulls are not permitted * @param entries The entries that will be added to the env map * @return {@code this} builder for use in a chained invocation */ public final Builder putAllEnv(Map entries) { if (this.env == null) { this.env = new LinkedHashMap(); } for (Map.Entry e : entries.entrySet()) { String k = e.getKey(); String v = e.getValue(); this.env.put( Objects.requireNonNull(k, "env key"), Objects.requireNonNull(v, v == null ? "env value for key: " + k : null)); } return this; } /** * Builds a new {@link ImmutableApplicationToCreateDto ImmutableApplicationToCreateDto}. * @return An immutable instance of ApplicationToCreateDto * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableApplicationToCreateDto build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableApplicationToCreateDto( name, staging, diskQuotaInMb, memoryInMb, metadata, routes == null ? null : createUnmodifiableSet(routes), env == null ? null : createUnmodifiableMap(false, false, env)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build ApplicationToCreateDto, some of required attributes are not set " + attributes; } } private static List createSafeList(Iterable iterable, boolean checkNulls, boolean skipNulls) { ArrayList list; if (iterable instanceof Collection) { int size = ((Collection) iterable).size(); if (size == 0) return Collections.emptyList(); list = new ArrayList<>(size); } else { list = new ArrayList<>(); } for (T element : iterable) { if (skipNulls && element == null) continue; if (checkNulls) Objects.requireNonNull(element, "element"); list.add(element); } return list; } /** Unmodifiable set constructed from list to avoid rehashing. */ private static Set createUnmodifiableSet(List list) { switch(list.size()) { case 0: return Collections.emptySet(); case 1: return Collections.singleton(list.get(0)); default: Set set = new LinkedHashSet<>(list.size() * 4 / 3 + 1); set.addAll(list); return Collections.unmodifiableSet(set); } } 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, 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 (java.util.Map.Entry e : map.entrySet()) { K k = e.getKey(); V v = e.getValue(); if (skipNulls) { if (k == null || v == null) continue; } else if (checkNulls) { java.util.Objects.requireNonNull(k, "key"); java.util.Objects.requireNonNull(v, v == null ? "value for key: " + k : null); } linkedMap.put(k, v); } } else { linkedMap.putAll(map); } return java.util.Collections.unmodifiableMap(linkedMap); } } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy