org.cloudfoundry.client.v2.organizations.RemoveOrganizationUserByUsernameRequest Maven / Gradle / Ivy
package org.cloudfoundry.client.v2.organizations;
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.cloudfoundry.Nullable;
import org.immutables.value.Generated;
/**
* The request payload for the Disassociate User with the Organization by Username operation
*/
@Generated(from = "_RemoveOrganizationUserByUsernameRequest", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class RemoveOrganizationUserByUsernameRequest
extends org.cloudfoundry.client.v2.organizations._RemoveOrganizationUserByUsernameRequest {
private final String organizationId;
private final @Nullable String origin;
private final String username;
private RemoveOrganizationUserByUsernameRequest(RemoveOrganizationUserByUsernameRequest.Builder builder) {
this.organizationId = builder.organizationId;
this.origin = builder.origin;
this.username = builder.username;
}
/**
* The organization id
*/
@JsonProperty("organizationId")
@JsonIgnore
@Override
public String getOrganizationId() {
return organizationId;
}
/**
* The origin
*/
@JsonProperty("origin")
@Override
public @Nullable String getOrigin() {
return origin;
}
/**
* The username
*/
@JsonProperty("username")
@Override
public String getUsername() {
return username;
}
/**
* This instance is equal to all instances of {@code RemoveOrganizationUserByUsernameRequest} 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 RemoveOrganizationUserByUsernameRequest
&& equalTo(0, (RemoveOrganizationUserByUsernameRequest) another);
}
private boolean equalTo(int synthetic, RemoveOrganizationUserByUsernameRequest another) {
return organizationId.equals(another.organizationId)
&& Objects.equals(origin, another.origin)
&& username.equals(another.username);
}
/**
* Computes a hash code from attributes: {@code organizationId}, {@code origin}, {@code username}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + organizationId.hashCode();
h += (h << 5) + Objects.hashCode(origin);
h += (h << 5) + username.hashCode();
return h;
}
/**
* Prints the immutable value {@code RemoveOrganizationUserByUsernameRequest} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "RemoveOrganizationUserByUsernameRequest{"
+ "organizationId=" + organizationId
+ ", origin=" + origin
+ ", username=" + username
+ "}";
}
/**
* 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 = "_RemoveOrganizationUserByUsernameRequest", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json
extends org.cloudfoundry.client.v2.organizations._RemoveOrganizationUserByUsernameRequest {
String organizationId;
String origin;
String username;
@JsonProperty("organizationId")
@JsonIgnore
public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}
@JsonProperty("origin")
public void setOrigin(@Nullable String origin) {
this.origin = origin;
}
@JsonProperty("username")
public void setUsername(String username) {
this.username = username;
}
@Override
public String getOrganizationId() { throw new UnsupportedOperationException(); }
@Override
public String getOrigin() { throw new UnsupportedOperationException(); }
@Override
public String getUsername() { 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 RemoveOrganizationUserByUsernameRequest fromJson(Json json) {
RemoveOrganizationUserByUsernameRequest.Builder builder = RemoveOrganizationUserByUsernameRequest.builder();
if (json.organizationId != null) {
builder.organizationId(json.organizationId);
}
if (json.origin != null) {
builder.origin(json.origin);
}
if (json.username != null) {
builder.username(json.username);
}
return builder.build();
}
/**
* Creates a builder for {@link RemoveOrganizationUserByUsernameRequest RemoveOrganizationUserByUsernameRequest}.
*
* RemoveOrganizationUserByUsernameRequest.builder()
* .organizationId(String) // required {@link RemoveOrganizationUserByUsernameRequest#getOrganizationId() organizationId}
* .origin(String | null) // nullable {@link RemoveOrganizationUserByUsernameRequest#getOrigin() origin}
* .username(String) // required {@link RemoveOrganizationUserByUsernameRequest#getUsername() username}
* .build();
*
* @return A new RemoveOrganizationUserByUsernameRequest builder
*/
public static RemoveOrganizationUserByUsernameRequest.Builder builder() {
return new RemoveOrganizationUserByUsernameRequest.Builder();
}
/**
* Builds instances of type {@link RemoveOrganizationUserByUsernameRequest RemoveOrganizationUserByUsernameRequest}.
* 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 = "_RemoveOrganizationUserByUsernameRequest", generator = "Immutables")
public static final class Builder {
private static final long INIT_BIT_ORGANIZATION_ID = 0x1L;
private static final long INIT_BIT_USERNAME = 0x2L;
private long initBits = 0x3L;
private String organizationId;
private String origin;
private String username;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code RemoveOrganizationUserByUsernameRequest} 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(RemoveOrganizationUserByUsernameRequest instance) {
return from((_RemoveOrganizationUserByUsernameRequest) instance);
}
/**
* Copy abstract value type {@code _RemoveOrganizationUserByUsernameRequest} 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(_RemoveOrganizationUserByUsernameRequest instance) {
Objects.requireNonNull(instance, "instance");
organizationId(instance.getOrganizationId());
String originValue = instance.getOrigin();
if (originValue != null) {
origin(originValue);
}
username(instance.getUsername());
return this;
}
/**
* Initializes the value for the {@link RemoveOrganizationUserByUsernameRequest#getOrganizationId() organizationId} attribute.
* @param organizationId The value for organizationId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder organizationId(String organizationId) {
this.organizationId = Objects.requireNonNull(organizationId, "organizationId");
initBits &= ~INIT_BIT_ORGANIZATION_ID;
return this;
}
/**
* Initializes the value for the {@link RemoveOrganizationUserByUsernameRequest#getOrigin() origin} attribute.
* @param origin The value for origin (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder origin(@Nullable String origin) {
this.origin = origin;
return this;
}
/**
* Initializes the value for the {@link RemoveOrganizationUserByUsernameRequest#getUsername() username} attribute.
* @param username The value for username
* @return {@code this} builder for use in a chained invocation
*/
public final Builder username(String username) {
this.username = Objects.requireNonNull(username, "username");
initBits &= ~INIT_BIT_USERNAME;
return this;
}
/**
* Builds a new {@link RemoveOrganizationUserByUsernameRequest RemoveOrganizationUserByUsernameRequest}.
* @return An immutable instance of RemoveOrganizationUserByUsernameRequest
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public RemoveOrganizationUserByUsernameRequest build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new RemoveOrganizationUserByUsernameRequest(this);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_ORGANIZATION_ID) != 0) attributes.add("organizationId");
if ((initBits & INIT_BIT_USERNAME) != 0) attributes.add("username");
return "Cannot build RemoveOrganizationUserByUsernameRequest, some of required attributes are not set " + attributes;
}
}
}