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