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

org.cloudfoundry.client.lib.domain.ImmutableDockerInfo 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.List;
import java.util.Objects;
import org.cloudfoundry.client.lib.domain.annotation.Nullable;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableDockerInfo.builder()}. */ @Generated(from = "DockerInfo", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableDockerInfo implements DockerInfo { private final String image; private final @Nullable DockerCredentials credentials; private ImmutableDockerInfo( String image, @Nullable DockerCredentials credentials) { this.image = image; this.credentials = credentials; } /** * @return The value of the {@code image} attribute */ @JsonProperty("image") @Override public String getImage() { return image; } /** * @return The value of the {@code credentials} attribute */ @JsonProperty("credentials") @Override public @Nullable DockerCredentials getCredentials() { return credentials; } /** * Copy the current immutable object by setting a value for the {@link DockerInfo#getImage() image} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for image * @return A modified copy of the {@code this} object */ public final ImmutableDockerInfo withImage(String value) { String newValue = Objects.requireNonNull(value, "image"); if (this.image.equals(newValue)) return this; return new ImmutableDockerInfo(newValue, this.credentials); } /** * Copy the current immutable object by setting a value for the {@link DockerInfo#getCredentials() credentials} 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 credentials (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableDockerInfo withCredentials(@Nullable DockerCredentials value) { if (this.credentials == value) return this; return new ImmutableDockerInfo(this.image, value); } /** * This instance is equal to all instances of {@code ImmutableDockerInfo} 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 ImmutableDockerInfo && equalTo((ImmutableDockerInfo) another); } private boolean equalTo(ImmutableDockerInfo another) { return image.equals(another.image) && Objects.equals(credentials, another.credentials); } /** * Computes a hash code from attributes: {@code image}, {@code credentials}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + image.hashCode(); h += (h << 5) + Objects.hashCode(credentials); return h; } /** * Prints the immutable value {@code DockerInfo} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "DockerInfo{" + "image=" + image + ", credentials=" + credentials + "}"; } /** * 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 = "DockerInfo", generator = "Immutables") @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements DockerInfo { String image; DockerCredentials credentials; @JsonProperty("image") public void setImage(String image) { this.image = image; } @JsonProperty("credentials") public void setCredentials(@Nullable DockerCredentials credentials) { this.credentials = credentials; } @Override public String getImage() { throw new UnsupportedOperationException(); } @Override public DockerCredentials getCredentials() { 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 ImmutableDockerInfo fromJson(Json json) { ImmutableDockerInfo.Builder builder = ImmutableDockerInfo.builder(); if (json.image != null) { builder.image(json.image); } if (json.credentials != null) { builder.credentials(json.credentials); } return builder.build(); } /** * Creates an immutable copy of a {@link DockerInfo} 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 DockerInfo instance */ public static ImmutableDockerInfo copyOf(DockerInfo instance) { if (instance instanceof ImmutableDockerInfo) { return (ImmutableDockerInfo) instance; } return ImmutableDockerInfo.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableDockerInfo ImmutableDockerInfo}. *

   * ImmutableDockerInfo.builder()
   *    .image(String) // required {@link DockerInfo#getImage() image}
   *    .credentials(org.cloudfoundry.client.lib.domain.DockerCredentials | null) // nullable {@link DockerInfo#getCredentials() credentials}
   *    .build();
   * 
* @return A new ImmutableDockerInfo builder */ public static ImmutableDockerInfo.Builder builder() { return new ImmutableDockerInfo.Builder(); } /** * Builds instances of type {@link ImmutableDockerInfo ImmutableDockerInfo}. * 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 = "DockerInfo", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_IMAGE = 0x1L; private long initBits = 0x1L; private String image; private DockerCredentials credentials; private Builder() { } /** * Fill a builder with attribute values from the provided {@code DockerInfo} 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(DockerInfo instance) { Objects.requireNonNull(instance, "instance"); image(instance.getImage()); @Nullable DockerCredentials credentialsValue = instance.getCredentials(); if (credentialsValue != null) { credentials(credentialsValue); } return this; } /** * Initializes the value for the {@link DockerInfo#getImage() image} attribute. * @param image The value for image * @return {@code this} builder for use in a chained invocation */ @JsonProperty("image") public final Builder image(String image) { this.image = Objects.requireNonNull(image, "image"); initBits &= ~INIT_BIT_IMAGE; return this; } /** * Initializes the value for the {@link DockerInfo#getCredentials() credentials} attribute. * @param credentials The value for credentials (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("credentials") public final Builder credentials(@Nullable DockerCredentials credentials) { this.credentials = credentials; return this; } /** * Builds a new {@link ImmutableDockerInfo ImmutableDockerInfo}. * @return An immutable instance of DockerInfo * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableDockerInfo build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableDockerInfo(image, credentials); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_IMAGE) != 0) attributes.add("image"); return "Cannot build DockerInfo, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy