org.cloudfoundry.client.v3.builds.CreatedBy Maven / Gradle / Ivy
package org.cloudfoundry.client.v3.builds;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.immutables.value.Generated;
/**
* Information about who created a build
*/
@Generated(from = "_CreatedBy", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class CreatedBy extends org.cloudfoundry.client.v3.builds._CreatedBy {
private final String email;
private final String id;
private final String name;
private CreatedBy(CreatedBy.Builder builder) {
this.email = builder.email;
this.id = builder.id;
this.name = builder.name;
}
/**
* The email
*/
@JsonProperty("email")
@Override
public String getEmail() {
return email;
}
/**
* The id
*/
@JsonProperty("guid")
@Override
public String getId() {
return id;
}
/**
* The name
*/
@JsonProperty("name")
@Override
public String getName() {
return name;
}
/**
* This instance is equal to all instances of {@code CreatedBy} 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 CreatedBy
&& equalTo(0, (CreatedBy) another);
}
private boolean equalTo(int synthetic, CreatedBy another) {
return email.equals(another.email)
&& id.equals(another.id)
&& name.equals(another.name);
}
/**
* Computes a hash code from attributes: {@code email}, {@code id}, {@code name}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + email.hashCode();
h += (h << 5) + id.hashCode();
h += (h << 5) + name.hashCode();
return h;
}
/**
* Prints the immutable value {@code CreatedBy} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "CreatedBy{"
+ "email=" + email
+ ", id=" + id
+ ", name=" + name
+ "}";
}
/**
* 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 = "_CreatedBy", generator = "Immutables")
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json extends org.cloudfoundry.client.v3.builds._CreatedBy {
String email;
String id;
String name;
@JsonProperty("email")
public void setEmail(String email) {
this.email = email;
}
@JsonProperty("guid")
public void setId(String id) {
this.id = id;
}
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
@Override
public String getEmail() { throw new UnsupportedOperationException(); }
@Override
public String getId() { throw new UnsupportedOperationException(); }
@Override
public String getName() { 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 CreatedBy fromJson(Json json) {
CreatedBy.Builder builder = CreatedBy.builder();
if (json.email != null) {
builder.email(json.email);
}
if (json.id != null) {
builder.id(json.id);
}
if (json.name != null) {
builder.name(json.name);
}
return builder.build();
}
/**
* Creates a builder for {@link CreatedBy CreatedBy}.
*
* CreatedBy.builder()
* .email(String) // required {@link CreatedBy#getEmail() email}
* .id(String) // required {@link CreatedBy#getId() id}
* .name(String) // required {@link CreatedBy#getName() name}
* .build();
*
* @return A new CreatedBy builder
*/
public static CreatedBy.Builder builder() {
return new CreatedBy.Builder();
}
/**
* Builds instances of type {@link CreatedBy CreatedBy}.
* 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 = "_CreatedBy", generator = "Immutables")
public static final class Builder {
private static final long INIT_BIT_EMAIL = 0x1L;
private static final long INIT_BIT_ID = 0x2L;
private static final long INIT_BIT_NAME = 0x4L;
private long initBits = 0x7L;
private String email;
private String id;
private String name;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code CreatedBy} 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(CreatedBy instance) {
return from((_CreatedBy) instance);
}
/**
* Copy abstract value type {@code _CreatedBy} 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(_CreatedBy instance) {
Objects.requireNonNull(instance, "instance");
email(instance.getEmail());
id(instance.getId());
name(instance.getName());
return this;
}
/**
* Initializes the value for the {@link CreatedBy#getEmail() email} attribute.
* @param email The value for email
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("email")
public final Builder email(String email) {
this.email = Objects.requireNonNull(email, "email");
initBits &= ~INIT_BIT_EMAIL;
return this;
}
/**
* Initializes the value for the {@link CreatedBy#getId() id} attribute.
* @param id The value for id
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("guid")
public final Builder id(String id) {
this.id = Objects.requireNonNull(id, "id");
initBits &= ~INIT_BIT_ID;
return this;
}
/**
* Initializes the value for the {@link CreatedBy#getName() name} attribute.
* @param name The value for name
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("name")
public final Builder name(String name) {
this.name = Objects.requireNonNull(name, "name");
initBits &= ~INIT_BIT_NAME;
return this;
}
/**
* Builds a new {@link CreatedBy CreatedBy}.
* @return An immutable instance of CreatedBy
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public CreatedBy build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new CreatedBy(this);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_EMAIL) != 0) attributes.add("email");
if ((initBits & INIT_BIT_ID) != 0) attributes.add("id");
if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name");
return "Cannot build CreatedBy, some of required attributes are not set " + attributes;
}
}
}