
com.sap.cloudfoundry.client.facade.adapters.ImmutableRawCloudApplication Maven / Gradle / Ivy
Show all versions of cloudfoundry-client-facade Show documentation
package com.sap.cloudfoundry.client.facade.adapters;
import com.sap.cloudfoundry.client.facade.domain.CloudSpace;
import com.sap.cloudfoundry.client.facade.domain.Derivable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.client.v3.applications.Application;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link RawCloudApplication}.
*
* Use the builder to create immutable instances:
* {@code ImmutableRawCloudApplication.builder()}.
*/
@Generated(from = "RawCloudApplication", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableRawCloudApplication
extends RawCloudApplication {
private final Application application;
private final Derivable space;
private ImmutableRawCloudApplication(
Application application,
Derivable space) {
this.application = application;
this.space = space;
}
/**
* @return The value of the {@code application} attribute
*/
@Override
public Application getApplication() {
return application;
}
/**
* @return The value of the {@code space} attribute
*/
@Override
public Derivable getSpace() {
return space;
}
/**
* Copy the current immutable object by setting a value for the {@link RawCloudApplication#getApplication() application} 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 application
* @return A modified copy of the {@code this} object
*/
public final ImmutableRawCloudApplication withApplication(Application value) {
if (this.application == value) return this;
Application newValue = Objects.requireNonNull(value, "application");
return new ImmutableRawCloudApplication(newValue, this.space);
}
/**
* Copy the current immutable object by setting a value for the {@link RawCloudApplication#getSpace() space} 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 space
* @return A modified copy of the {@code this} object
*/
public final ImmutableRawCloudApplication withSpace(Derivable value) {
if (this.space == value) return this;
Derivable newValue = Objects.requireNonNull(value, "space");
return new ImmutableRawCloudApplication(this.application, newValue);
}
/**
* This instance is equal to all instances of {@code ImmutableRawCloudApplication} 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 ImmutableRawCloudApplication
&& equalTo(0, (ImmutableRawCloudApplication) another);
}
private boolean equalTo(int synthetic, ImmutableRawCloudApplication another) {
return application.equals(another.application)
&& space.equals(another.space);
}
/**
* Computes a hash code from attributes: {@code application}, {@code space}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + application.hashCode();
h += (h << 5) + space.hashCode();
return h;
}
/**
* Prints the immutable value {@code RawCloudApplication} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "RawCloudApplication{"
+ "application=" + application
+ ", space=" + space
+ "}";
}
/**
* Creates an immutable copy of a {@link RawCloudApplication} 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 RawCloudApplication instance
*/
public static ImmutableRawCloudApplication copyOf(RawCloudApplication instance) {
if (instance instanceof ImmutableRawCloudApplication) {
return (ImmutableRawCloudApplication) instance;
}
return ImmutableRawCloudApplication.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableRawCloudApplication ImmutableRawCloudApplication}.
*
* ImmutableRawCloudApplication.builder()
* .application(org.cloudfoundry.client.v3.applications.Application) // required {@link RawCloudApplication#getApplication() application}
* .space(com.sap.cloudfoundry.client.facade.domain.Derivable<com.sap.cloudfoundry.client.facade.domain.CloudSpace>) // required {@link RawCloudApplication#getSpace() space}
* .build();
*
* @return A new ImmutableRawCloudApplication builder
*/
public static ImmutableRawCloudApplication.Builder builder() {
return new ImmutableRawCloudApplication.Builder();
}
/**
* Builds instances of type {@link ImmutableRawCloudApplication ImmutableRawCloudApplication}.
* 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 = "RawCloudApplication", generator = "Immutables")
public static final class Builder {
private static final long INIT_BIT_APPLICATION = 0x1L;
private static final long INIT_BIT_SPACE = 0x2L;
private long initBits = 0x3L;
private Application application;
private Derivable space;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code RawCloudApplication} 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(RawCloudApplication instance) {
Objects.requireNonNull(instance, "instance");
this.application(instance.getApplication());
this.space(instance.getSpace());
return this;
}
/**
* Initializes the value for the {@link RawCloudApplication#getApplication() application} attribute.
* @param application The value for application
* @return {@code this} builder for use in a chained invocation
*/
public final Builder application(Application application) {
this.application = Objects.requireNonNull(application, "application");
initBits &= ~INIT_BIT_APPLICATION;
return this;
}
/**
* Initializes the value for the {@link RawCloudApplication#getSpace() space} attribute.
* @param space The value for space
* @return {@code this} builder for use in a chained invocation
*/
public final Builder space(Derivable space) {
this.space = Objects.requireNonNull(space, "space");
initBits &= ~INIT_BIT_SPACE;
return this;
}
/**
* Builds a new {@link ImmutableRawCloudApplication ImmutableRawCloudApplication}.
* @return An immutable instance of RawCloudApplication
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableRawCloudApplication build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableRawCloudApplication(application, space);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_APPLICATION) != 0) attributes.add("application");
if ((initBits & INIT_BIT_SPACE) != 0) attributes.add("space");
return "Cannot build RawCloudApplication, some of required attributes are not set " + attributes;
}
}
}