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