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