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

org.cloudfoundry.client.lib.adapters.ImmutableRawV2CloudDomain Maven / Gradle / Ivy

The newest version!
package org.cloudfoundry.client.lib.adapters;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.client.v2.Resource;
import org.cloudfoundry.client.v2.domains.DomainEntity;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableRawV2CloudDomain.builder()}. * Use the static factory method to create immutable instances: * {@code ImmutableRawV2CloudDomain.of()}. */ @Generated(from = "RawV2CloudDomain", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableRawV2CloudDomain extends RawV2CloudDomain { private final Resource resource; private ImmutableRawV2CloudDomain(Resource resource) { this.resource = Objects.requireNonNull(resource, "resource"); } private ImmutableRawV2CloudDomain( ImmutableRawV2CloudDomain original, Resource resource) { this.resource = resource; } /** * @return The value of the {@code resource} attribute */ @Override public Resource getResource() { return resource; } /** * Copy the current immutable object by setting a value for the {@link RawV2CloudDomain#getResource() resource} 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 resource * @return A modified copy of the {@code this} object */ public final ImmutableRawV2CloudDomain withResource(Resource value) { if (this.resource == value) return this; Resource newValue = Objects.requireNonNull(value, "resource"); return new ImmutableRawV2CloudDomain(this, newValue); } /** * This instance is equal to all instances of {@code ImmutableRawV2CloudDomain} 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 ImmutableRawV2CloudDomain && equalTo((ImmutableRawV2CloudDomain) another); } private boolean equalTo(ImmutableRawV2CloudDomain another) { return resource.equals(another.resource); } /** * Computes a hash code from attributes: {@code resource}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + resource.hashCode(); return h; } /** * Prints the immutable value {@code RawV2CloudDomain} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "RawV2CloudDomain{" + "resource=" + resource + "}"; } /** * Construct a new immutable {@code RawV2CloudDomain} instance. * @param resource The value for the {@code resource} attribute * @return An immutable RawV2CloudDomain instance */ public static ImmutableRawV2CloudDomain of(Resource resource) { return new ImmutableRawV2CloudDomain(resource); } /** * Creates an immutable copy of a {@link RawV2CloudDomain} 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 RawV2CloudDomain instance */ public static ImmutableRawV2CloudDomain copyOf(RawV2CloudDomain instance) { if (instance instanceof ImmutableRawV2CloudDomain) { return (ImmutableRawV2CloudDomain) instance; } return ImmutableRawV2CloudDomain.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableRawV2CloudDomain ImmutableRawV2CloudDomain}. *

   * ImmutableRawV2CloudDomain.builder()
   *    .resource(org.cloudfoundry.client.v2.Resource&lt;org.cloudfoundry.client.v2.domains.DomainEntity&gt;) // required {@link RawV2CloudDomain#getResource() resource}
   *    .build();
   * 
* @return A new ImmutableRawV2CloudDomain builder */ public static ImmutableRawV2CloudDomain.Builder builder() { return new ImmutableRawV2CloudDomain.Builder(); } /** * Builds instances of type {@link ImmutableRawV2CloudDomain ImmutableRawV2CloudDomain}. * 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 = "RawV2CloudDomain", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_RESOURCE = 0x1L; private long initBits = 0x1L; private Resource resource; private Builder() { } /** * Fill a builder with attribute values from the provided {@code RawV2CloudDomain} 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(RawV2CloudDomain instance) { Objects.requireNonNull(instance, "instance"); resource(instance.getResource()); return this; } /** * Initializes the value for the {@link RawV2CloudDomain#getResource() resource} attribute. * @param resource The value for resource * @return {@code this} builder for use in a chained invocation */ public final Builder resource(Resource resource) { this.resource = Objects.requireNonNull(resource, "resource"); initBits &= ~INIT_BIT_RESOURCE; return this; } /** * Builds a new {@link ImmutableRawV2CloudDomain ImmutableRawV2CloudDomain}. * @return An immutable instance of RawV2CloudDomain * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableRawV2CloudDomain build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableRawV2CloudDomain(null, resource); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_RESOURCE) != 0) attributes.add("resource"); return "Cannot build RawV2CloudDomain, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy