org.cloudfoundry.client.lib.domain.ImmutableCloudMetadata Maven / Gradle / Ivy
Show all versions of cloudfoundry-client-lib Show documentation
package org.cloudfoundry.client.lib.domain;
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.Date;
import java.util.Objects;
import java.util.UUID;
import org.cloudfoundry.client.lib.domain.annotation.Nullable;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link CloudMetadata}.
*
* Use the builder to create immutable instances:
* {@code ImmutableCloudMetadata.builder()}.
* Use the static factory method to create immutable instances:
* {@code ImmutableCloudMetadata.of()}.
*/
@Generated(from = "CloudMetadata", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableCloudMetadata implements CloudMetadata {
private final @Nullable UUID guid;
private final @Nullable Date createdAt;
private final @Nullable Date updatedAt;
private final @Nullable String url;
private ImmutableCloudMetadata(@Nullable UUID guid) {
this.guid = guid;
this.createdAt = null;
this.updatedAt = null;
this.url = null;
}
private ImmutableCloudMetadata(
@Nullable UUID guid,
@Nullable Date createdAt,
@Nullable Date updatedAt,
@Nullable String url) {
this.guid = guid;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
this.url = url;
}
/**
* @return The value of the {@code guid} attribute
*/
@JsonProperty("guid")
@Override
public @Nullable UUID getGuid() {
return guid;
}
/**
* @return The value of the {@code createdAt} attribute
*/
@JsonProperty("createdAt")
@Override
public @Nullable Date getCreatedAt() {
return createdAt;
}
/**
* @return The value of the {@code updatedAt} attribute
*/
@JsonProperty("updatedAt")
@Override
public @Nullable Date getUpdatedAt() {
return updatedAt;
}
/**
* @return The value of the {@code url} attribute
*/
@JsonProperty("url")
@Override
public @Nullable String getUrl() {
return url;
}
/**
* Copy the current immutable object by setting a value for the {@link CloudMetadata#getGuid() guid} 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 guid (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudMetadata withGuid(@Nullable UUID value) {
if (this.guid == value) return this;
return new ImmutableCloudMetadata(value, this.createdAt, this.updatedAt, this.url);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudMetadata#getCreatedAt() createdAt} 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 createdAt (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudMetadata withCreatedAt(@Nullable Date value) {
if (this.createdAt == value) return this;
return new ImmutableCloudMetadata(this.guid, value, this.updatedAt, this.url);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudMetadata#getUpdatedAt() updatedAt} 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 updatedAt (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudMetadata withUpdatedAt(@Nullable Date value) {
if (this.updatedAt == value) return this;
return new ImmutableCloudMetadata(this.guid, this.createdAt, value, this.url);
}
/**
* Copy the current immutable object by setting a value for the {@link CloudMetadata#getUrl() url} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for url (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableCloudMetadata withUrl(@Nullable String value) {
if (Objects.equals(this.url, value)) return this;
return new ImmutableCloudMetadata(this.guid, this.createdAt, this.updatedAt, value);
}
/**
* This instance is equal to all instances of {@code ImmutableCloudMetadata} 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 ImmutableCloudMetadata
&& equalTo((ImmutableCloudMetadata) another);
}
private boolean equalTo(ImmutableCloudMetadata another) {
return Objects.equals(guid, another.guid)
&& Objects.equals(createdAt, another.createdAt)
&& Objects.equals(updatedAt, another.updatedAt)
&& Objects.equals(url, another.url);
}
/**
* Computes a hash code from attributes: {@code guid}, {@code createdAt}, {@code updatedAt}, {@code url}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(guid);
h += (h << 5) + Objects.hashCode(createdAt);
h += (h << 5) + Objects.hashCode(updatedAt);
h += (h << 5) + Objects.hashCode(url);
return h;
}
/**
* Prints the immutable value {@code CloudMetadata} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "CloudMetadata{"
+ "guid=" + guid
+ ", createdAt=" + createdAt
+ ", updatedAt=" + updatedAt
+ ", url=" + url
+ "}";
}
/**
* 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 = "CloudMetadata", generator = "Immutables")
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements CloudMetadata {
UUID guid;
Date createdAt;
Date updatedAt;
String url;
@JsonProperty("guid")
public void setGuid(@Nullable UUID guid) {
this.guid = guid;
}
@JsonProperty("createdAt")
public void setCreatedAt(@Nullable Date createdAt) {
this.createdAt = createdAt;
}
@JsonProperty("updatedAt")
public void setUpdatedAt(@Nullable Date updatedAt) {
this.updatedAt = updatedAt;
}
@JsonProperty("url")
public void setUrl(@Nullable String url) {
this.url = url;
}
@Override
public UUID getGuid() { throw new UnsupportedOperationException(); }
@Override
public Date getCreatedAt() { throw new UnsupportedOperationException(); }
@Override
public Date getUpdatedAt() { throw new UnsupportedOperationException(); }
@Override
public String getUrl() { 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 ImmutableCloudMetadata fromJson(Json json) {
ImmutableCloudMetadata.Builder builder = ImmutableCloudMetadata.builder();
if (json.guid != null) {
builder.guid(json.guid);
}
if (json.createdAt != null) {
builder.createdAt(json.createdAt);
}
if (json.updatedAt != null) {
builder.updatedAt(json.updatedAt);
}
if (json.url != null) {
builder.url(json.url);
}
return builder.build();
}
/**
* Construct a new immutable {@code CloudMetadata} instance.
* @param guid The value for the {@code guid} attribute
* @return An immutable CloudMetadata instance
*/
public static ImmutableCloudMetadata of(@Nullable UUID guid) {
return new ImmutableCloudMetadata(guid);
}
/**
* Creates an immutable copy of a {@link CloudMetadata} 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 CloudMetadata instance
*/
public static ImmutableCloudMetadata copyOf(CloudMetadata instance) {
if (instance instanceof ImmutableCloudMetadata) {
return (ImmutableCloudMetadata) instance;
}
return ImmutableCloudMetadata.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableCloudMetadata ImmutableCloudMetadata}.
*
* ImmutableCloudMetadata.builder()
* .guid(UUID | null) // nullable {@link CloudMetadata#getGuid() guid}
* .createdAt(Date | null) // nullable {@link CloudMetadata#getCreatedAt() createdAt}
* .updatedAt(Date | null) // nullable {@link CloudMetadata#getUpdatedAt() updatedAt}
* .url(String | null) // nullable {@link CloudMetadata#getUrl() url}
* .build();
*
* @return A new ImmutableCloudMetadata builder
*/
public static ImmutableCloudMetadata.Builder builder() {
return new ImmutableCloudMetadata.Builder();
}
/**
* Builds instances of type {@link ImmutableCloudMetadata ImmutableCloudMetadata}.
* 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 = "CloudMetadata", generator = "Immutables")
public static final class Builder {
private UUID guid;
private Date createdAt;
private Date updatedAt;
private String url;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code CloudMetadata} 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(CloudMetadata instance) {
Objects.requireNonNull(instance, "instance");
@Nullable UUID guidValue = instance.getGuid();
if (guidValue != null) {
guid(guidValue);
}
@Nullable Date createdAtValue = instance.getCreatedAt();
if (createdAtValue != null) {
createdAt(createdAtValue);
}
@Nullable Date updatedAtValue = instance.getUpdatedAt();
if (updatedAtValue != null) {
updatedAt(updatedAtValue);
}
@Nullable String urlValue = instance.getUrl();
if (urlValue != null) {
url(urlValue);
}
return this;
}
/**
* Initializes the value for the {@link CloudMetadata#getGuid() guid} attribute.
* @param guid The value for guid (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("guid")
public final Builder guid(@Nullable UUID guid) {
this.guid = guid;
return this;
}
/**
* Initializes the value for the {@link CloudMetadata#getCreatedAt() createdAt} attribute.
* @param createdAt The value for createdAt (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("createdAt")
public final Builder createdAt(@Nullable Date createdAt) {
this.createdAt = createdAt;
return this;
}
/**
* Initializes the value for the {@link CloudMetadata#getUpdatedAt() updatedAt} attribute.
* @param updatedAt The value for updatedAt (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("updatedAt")
public final Builder updatedAt(@Nullable Date updatedAt) {
this.updatedAt = updatedAt;
return this;
}
/**
* Initializes the value for the {@link CloudMetadata#getUrl() url} attribute.
* @param url The value for url (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("url")
public final Builder url(@Nullable String url) {
this.url = url;
return this;
}
/**
* Builds a new {@link ImmutableCloudMetadata ImmutableCloudMetadata}.
* @return An immutable instance of CloudMetadata
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableCloudMetadata build() {
return new ImmutableCloudMetadata(guid, createdAt, updatedAt, url);
}
}
}