org.cloudfoundry.client.v2.applications.CopyApplicationRequest Maven / Gradle / Ivy
package org.cloudfoundry.client.v2.applications;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.immutables.value.Generated;
/**
* The request payload for the Copy the Application operation
*/
@Generated(from = "_CopyApplicationRequest", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class CopyApplicationRequest
extends org.cloudfoundry.client.v2.applications._CopyApplicationRequest {
private final String applicationId;
private final String sourceApplicationId;
private CopyApplicationRequest(CopyApplicationRequest.Builder builder) {
this.applicationId = builder.applicationId;
this.sourceApplicationId = builder.sourceApplicationId;
}
/**
* The application id
*/
@JsonProperty("applicationId")
@JsonIgnore
@Override
public String getApplicationId() {
return applicationId;
}
/**
* The source application id
*/
@JsonProperty("source_app_guid")
@Override
public String getSourceApplicationId() {
return sourceApplicationId;
}
/**
* This instance is equal to all instances of {@code CopyApplicationRequest} 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 CopyApplicationRequest
&& equalTo(0, (CopyApplicationRequest) another);
}
private boolean equalTo(int synthetic, CopyApplicationRequest another) {
return applicationId.equals(another.applicationId)
&& sourceApplicationId.equals(another.sourceApplicationId);
}
/**
* Computes a hash code from attributes: {@code applicationId}, {@code sourceApplicationId}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + applicationId.hashCode();
h += (h << 5) + sourceApplicationId.hashCode();
return h;
}
/**
* Prints the immutable value {@code CopyApplicationRequest} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "CopyApplicationRequest{"
+ "applicationId=" + applicationId
+ ", sourceApplicationId=" + sourceApplicationId
+ "}";
}
/**
* Utility type used to correctly read immutable object from JSON representation.
* @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure
*/
@Generated(from = "_CopyApplicationRequest", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json extends org.cloudfoundry.client.v2.applications._CopyApplicationRequest {
String applicationId;
String sourceApplicationId;
@JsonProperty("applicationId")
@JsonIgnore
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
@JsonProperty("source_app_guid")
public void setSourceApplicationId(String sourceApplicationId) {
this.sourceApplicationId = sourceApplicationId;
}
@Override
public String getApplicationId() { throw new UnsupportedOperationException(); }
@Override
public String getSourceApplicationId() { throw new UnsupportedOperationException(); }
}
/**
* @param json A JSON-bindable data structure
* @return An immutable value type
* @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
static CopyApplicationRequest fromJson(Json json) {
CopyApplicationRequest.Builder builder = CopyApplicationRequest.builder();
if (json.applicationId != null) {
builder.applicationId(json.applicationId);
}
if (json.sourceApplicationId != null) {
builder.sourceApplicationId(json.sourceApplicationId);
}
return builder.build();
}
/**
* Creates a builder for {@link CopyApplicationRequest CopyApplicationRequest}.
*
* CopyApplicationRequest.builder()
* .applicationId(String) // required {@link CopyApplicationRequest#getApplicationId() applicationId}
* .sourceApplicationId(String) // required {@link CopyApplicationRequest#getSourceApplicationId() sourceApplicationId}
* .build();
*
* @return A new CopyApplicationRequest builder
*/
public static CopyApplicationRequest.Builder builder() {
return new CopyApplicationRequest.Builder();
}
/**
* Builds instances of type {@link CopyApplicationRequest CopyApplicationRequest}.
* 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 = "_CopyApplicationRequest", generator = "Immutables")
public static final class Builder {
private static final long INIT_BIT_APPLICATION_ID = 0x1L;
private static final long INIT_BIT_SOURCE_APPLICATION_ID = 0x2L;
private long initBits = 0x3L;
private String applicationId;
private String sourceApplicationId;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code CopyApplicationRequest} 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(CopyApplicationRequest instance) {
return from((_CopyApplicationRequest) instance);
}
/**
* Copy abstract value type {@code _CopyApplicationRequest} instance into builder.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
final Builder from(_CopyApplicationRequest instance) {
Objects.requireNonNull(instance, "instance");
applicationId(instance.getApplicationId());
sourceApplicationId(instance.getSourceApplicationId());
return this;
}
/**
* Initializes the value for the {@link CopyApplicationRequest#getApplicationId() applicationId} attribute.
* @param applicationId The value for applicationId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder applicationId(String applicationId) {
this.applicationId = Objects.requireNonNull(applicationId, "applicationId");
initBits &= ~INIT_BIT_APPLICATION_ID;
return this;
}
/**
* Initializes the value for the {@link CopyApplicationRequest#getSourceApplicationId() sourceApplicationId} attribute.
* @param sourceApplicationId The value for sourceApplicationId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder sourceApplicationId(String sourceApplicationId) {
this.sourceApplicationId = Objects.requireNonNull(sourceApplicationId, "sourceApplicationId");
initBits &= ~INIT_BIT_SOURCE_APPLICATION_ID;
return this;
}
/**
* Builds a new {@link CopyApplicationRequest CopyApplicationRequest}.
* @return An immutable instance of CopyApplicationRequest
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public CopyApplicationRequest build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new CopyApplicationRequest(this);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_APPLICATION_ID) != 0) attributes.add("applicationId");
if ((initBits & INIT_BIT_SOURCE_APPLICATION_ID) != 0) attributes.add("sourceApplicationId");
return "Cannot build CopyApplicationRequest, some of required attributes are not set " + attributes;
}
}
}