
com.sap.cloud.lm.sl.cf.persistence.model.ImmutableFileEntry Maven / Gradle / Ivy
package com.sap.cloud.lm.sl.cf.persistence.model;
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 com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.math.BigInteger;
import java.util.Date;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link FileEntry}.
*
* Use the builder to create immutable instances:
* {@code ImmutableFileEntry.builder()}.
*/
@Generated(from = "FileEntry", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableFileEntry implements FileEntry {
private final @Nullable String id;
private final @Nullable String name;
private final @Nullable String namespace;
private final @Nullable String space;
private final @Nullable BigInteger size;
private final @Nullable String digest;
private final @Nullable String digestAlgorithm;
private final @Nullable Date modified;
private ImmutableFileEntry(
@Nullable String id,
@Nullable String name,
@Nullable String namespace,
@Nullable String space,
@Nullable BigInteger size,
@Nullable String digest,
@Nullable String digestAlgorithm,
@Nullable Date modified) {
this.id = id;
this.name = name;
this.namespace = namespace;
this.space = space;
this.size = size;
this.digest = digest;
this.digestAlgorithm = digestAlgorithm;
this.modified = modified;
}
/**
* @return The value of the {@code id} attribute
*/
@JsonProperty("id")
@Override
public @Nullable String getId() {
return id;
}
/**
* @return The value of the {@code name} attribute
*/
@JsonProperty("name")
@Override
public @Nullable String getName() {
return name;
}
/**
* @return The value of the {@code namespace} attribute
*/
@JsonProperty("namespace")
@Override
public @Nullable String getNamespace() {
return namespace;
}
/**
* @return The value of the {@code space} attribute
*/
@JsonProperty("space")
@Override
public @Nullable String getSpace() {
return space;
}
/**
* @return The value of the {@code size} attribute
*/
@JsonProperty("size")
@Override
public @Nullable BigInteger getSize() {
return size;
}
/**
* @return The value of the {@code digest} attribute
*/
@JsonProperty("digest")
@Override
public @Nullable String getDigest() {
return digest;
}
/**
* @return The value of the {@code digestAlgorithm} attribute
*/
@JsonProperty("digestAlgorithm")
@Override
public @Nullable String getDigestAlgorithm() {
return digestAlgorithm;
}
/**
* @return The value of the {@code modified} attribute
*/
@JsonProperty("modified")
@Override
public @Nullable Date getModified() {
return modified;
}
/**
* Copy the current immutable object by setting a value for the {@link FileEntry#getId() id} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for id (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileEntry withId(@Nullable String value) {
if (Objects.equals(this.id, value)) return this;
return new ImmutableFileEntry(
value,
this.name,
this.namespace,
this.space,
this.size,
this.digest,
this.digestAlgorithm,
this.modified);
}
/**
* Copy the current immutable object by setting a value for the {@link FileEntry#getName() name} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for name (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileEntry withName(@Nullable String value) {
if (Objects.equals(this.name, value)) return this;
return new ImmutableFileEntry(
this.id,
value,
this.namespace,
this.space,
this.size,
this.digest,
this.digestAlgorithm,
this.modified);
}
/**
* Copy the current immutable object by setting a value for the {@link FileEntry#getNamespace() namespace} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for namespace (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileEntry withNamespace(@Nullable String value) {
if (Objects.equals(this.namespace, value)) return this;
return new ImmutableFileEntry(
this.id,
this.name,
value,
this.space,
this.size,
this.digest,
this.digestAlgorithm,
this.modified);
}
/**
* Copy the current immutable object by setting a value for the {@link FileEntry#getSpace() space} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for space (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileEntry withSpace(@Nullable String value) {
if (Objects.equals(this.space, value)) return this;
return new ImmutableFileEntry(
this.id,
this.name,
this.namespace,
value,
this.size,
this.digest,
this.digestAlgorithm,
this.modified);
}
/**
* Copy the current immutable object by setting a value for the {@link FileEntry#getSize() size} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for size (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileEntry withSize(@Nullable BigInteger value) {
if (Objects.equals(this.size, value)) return this;
return new ImmutableFileEntry(
this.id,
this.name,
this.namespace,
this.space,
value,
this.digest,
this.digestAlgorithm,
this.modified);
}
/**
* Copy the current immutable object by setting a value for the {@link FileEntry#getDigest() digest} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for digest (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileEntry withDigest(@Nullable String value) {
if (Objects.equals(this.digest, value)) return this;
return new ImmutableFileEntry(
this.id,
this.name,
this.namespace,
this.space,
this.size,
value,
this.digestAlgorithm,
this.modified);
}
/**
* Copy the current immutable object by setting a value for the {@link FileEntry#getDigestAlgorithm() digestAlgorithm} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for digestAlgorithm (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileEntry withDigestAlgorithm(@Nullable String value) {
if (Objects.equals(this.digestAlgorithm, value)) return this;
return new ImmutableFileEntry(this.id, this.name, this.namespace, this.space, this.size, this.digest, value, this.modified);
}
/**
* Copy the current immutable object by setting a value for the {@link FileEntry#getModified() modified} 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 modified (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableFileEntry withModified(@Nullable Date value) {
if (this.modified == value) return this;
return new ImmutableFileEntry(
this.id,
this.name,
this.namespace,
this.space,
this.size,
this.digest,
this.digestAlgorithm,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableFileEntry} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(@Nullable Object another) {
if (this == another) return true;
return another instanceof ImmutableFileEntry
&& equalTo((ImmutableFileEntry) another);
}
private boolean equalTo(ImmutableFileEntry another) {
return Objects.equals(id, another.id)
&& Objects.equals(name, another.name)
&& Objects.equals(namespace, another.namespace)
&& Objects.equals(space, another.space)
&& Objects.equals(size, another.size)
&& Objects.equals(digest, another.digest)
&& Objects.equals(digestAlgorithm, another.digestAlgorithm)
&& Objects.equals(modified, another.modified);
}
/**
* Computes a hash code from attributes: {@code id}, {@code name}, {@code namespace}, {@code space}, {@code size}, {@code digest}, {@code digestAlgorithm}, {@code modified}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + Objects.hashCode(id);
h += (h << 5) + Objects.hashCode(name);
h += (h << 5) + Objects.hashCode(namespace);
h += (h << 5) + Objects.hashCode(space);
h += (h << 5) + Objects.hashCode(size);
h += (h << 5) + Objects.hashCode(digest);
h += (h << 5) + Objects.hashCode(digestAlgorithm);
h += (h << 5) + Objects.hashCode(modified);
return h;
}
/**
* Prints the immutable value {@code FileEntry} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("FileEntry")
.omitNullValues()
.add("id", id)
.add("name", name)
.add("namespace", namespace)
.add("space", space)
.add("size", size)
.add("digest", digest)
.add("digestAlgorithm", digestAlgorithm)
.add("modified", modified)
.toString();
}
/**
* 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 = "FileEntry", generator = "Immutables")
@Deprecated
@SuppressWarnings("Immutable")
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements FileEntry {
@Nullable String id;
@Nullable String name;
@Nullable String namespace;
@Nullable String space;
@Nullable BigInteger size;
@Nullable String digest;
@Nullable String digestAlgorithm;
@Nullable Date modified;
@JsonProperty("id")
public void setId(@Nullable String id) {
this.id = id;
}
@JsonProperty("name")
public void setName(@Nullable String name) {
this.name = name;
}
@JsonProperty("namespace")
public void setNamespace(@Nullable String namespace) {
this.namespace = namespace;
}
@JsonProperty("space")
public void setSpace(@Nullable String space) {
this.space = space;
}
@JsonProperty("size")
public void setSize(@Nullable BigInteger size) {
this.size = size;
}
@JsonProperty("digest")
public void setDigest(@Nullable String digest) {
this.digest = digest;
}
@JsonProperty("digestAlgorithm")
public void setDigestAlgorithm(@Nullable String digestAlgorithm) {
this.digestAlgorithm = digestAlgorithm;
}
@JsonProperty("modified")
public void setModified(@Nullable Date modified) {
this.modified = modified;
}
@Override
public String getId() { throw new UnsupportedOperationException(); }
@Override
public String getName() { throw new UnsupportedOperationException(); }
@Override
public String getNamespace() { throw new UnsupportedOperationException(); }
@Override
public String getSpace() { throw new UnsupportedOperationException(); }
@Override
public BigInteger getSize() { throw new UnsupportedOperationException(); }
@Override
public String getDigest() { throw new UnsupportedOperationException(); }
@Override
public String getDigestAlgorithm() { throw new UnsupportedOperationException(); }
@Override
public Date getModified() { 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 ImmutableFileEntry fromJson(Json json) {
ImmutableFileEntry.Builder builder = ImmutableFileEntry.builder();
if (json.id != null) {
builder.id(json.id);
}
if (json.name != null) {
builder.name(json.name);
}
if (json.namespace != null) {
builder.namespace(json.namespace);
}
if (json.space != null) {
builder.space(json.space);
}
if (json.size != null) {
builder.size(json.size);
}
if (json.digest != null) {
builder.digest(json.digest);
}
if (json.digestAlgorithm != null) {
builder.digestAlgorithm(json.digestAlgorithm);
}
if (json.modified != null) {
builder.modified(json.modified);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link FileEntry} 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 FileEntry instance
*/
public static ImmutableFileEntry copyOf(FileEntry instance) {
if (instance instanceof ImmutableFileEntry) {
return (ImmutableFileEntry) instance;
}
return ImmutableFileEntry.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableFileEntry ImmutableFileEntry}.
*
* ImmutableFileEntry.builder()
* .id(String | null) // nullable {@link FileEntry#getId() id}
* .name(String | null) // nullable {@link FileEntry#getName() name}
* .namespace(String | null) // nullable {@link FileEntry#getNamespace() namespace}
* .space(String | null) // nullable {@link FileEntry#getSpace() space}
* .size(java.math.BigInteger | null) // nullable {@link FileEntry#getSize() size}
* .digest(String | null) // nullable {@link FileEntry#getDigest() digest}
* .digestAlgorithm(String | null) // nullable {@link FileEntry#getDigestAlgorithm() digestAlgorithm}
* .modified(Date | null) // nullable {@link FileEntry#getModified() modified}
* .build();
*
* @return A new ImmutableFileEntry builder
*/
public static ImmutableFileEntry.Builder builder() {
return new ImmutableFileEntry.Builder();
}
/**
* Builds instances of type {@link ImmutableFileEntry ImmutableFileEntry}.
* 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 = "FileEntry", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private @Nullable String id;
private @Nullable String name;
private @Nullable String namespace;
private @Nullable String space;
private @Nullable BigInteger size;
private @Nullable String digest;
private @Nullable String digestAlgorithm;
private @Nullable Date modified;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code FileEntry} 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
*/
@CanIgnoreReturnValue
public final Builder from(FileEntry instance) {
Objects.requireNonNull(instance, "instance");
@Nullable String idValue = instance.getId();
if (idValue != null) {
id(idValue);
}
@Nullable String nameValue = instance.getName();
if (nameValue != null) {
name(nameValue);
}
@Nullable String namespaceValue = instance.getNamespace();
if (namespaceValue != null) {
namespace(namespaceValue);
}
@Nullable String spaceValue = instance.getSpace();
if (spaceValue != null) {
space(spaceValue);
}
@Nullable BigInteger sizeValue = instance.getSize();
if (sizeValue != null) {
size(sizeValue);
}
@Nullable String digestValue = instance.getDigest();
if (digestValue != null) {
digest(digestValue);
}
@Nullable String digestAlgorithmValue = instance.getDigestAlgorithm();
if (digestAlgorithmValue != null) {
digestAlgorithm(digestAlgorithmValue);
}
@Nullable Date modifiedValue = instance.getModified();
if (modifiedValue != null) {
modified(modifiedValue);
}
return this;
}
/**
* Initializes the value for the {@link FileEntry#getId() id} attribute.
* @param id The value for id (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("id")
public final Builder id(@Nullable String id) {
this.id = id;
return this;
}
/**
* Initializes the value for the {@link FileEntry#getName() name} attribute.
* @param name The value for name (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("name")
public final Builder name(@Nullable String name) {
this.name = name;
return this;
}
/**
* Initializes the value for the {@link FileEntry#getNamespace() namespace} attribute.
* @param namespace The value for namespace (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("namespace")
public final Builder namespace(@Nullable String namespace) {
this.namespace = namespace;
return this;
}
/**
* Initializes the value for the {@link FileEntry#getSpace() space} attribute.
* @param space The value for space (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("space")
public final Builder space(@Nullable String space) {
this.space = space;
return this;
}
/**
* Initializes the value for the {@link FileEntry#getSize() size} attribute.
* @param size The value for size (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("size")
public final Builder size(@Nullable BigInteger size) {
this.size = size;
return this;
}
/**
* Initializes the value for the {@link FileEntry#getDigest() digest} attribute.
* @param digest The value for digest (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("digest")
public final Builder digest(@Nullable String digest) {
this.digest = digest;
return this;
}
/**
* Initializes the value for the {@link FileEntry#getDigestAlgorithm() digestAlgorithm} attribute.
* @param digestAlgorithm The value for digestAlgorithm (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("digestAlgorithm")
public final Builder digestAlgorithm(@Nullable String digestAlgorithm) {
this.digestAlgorithm = digestAlgorithm;
return this;
}
/**
* Initializes the value for the {@link FileEntry#getModified() modified} attribute.
* @param modified The value for modified (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("modified")
public final Builder modified(@Nullable Date modified) {
this.modified = modified;
return this;
}
/**
* Builds a new {@link ImmutableFileEntry ImmutableFileEntry}.
* @return An immutable instance of FileEntry
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableFileEntry build() {
return new ImmutableFileEntry(id, name, namespace, space, size, digest, digestAlgorithm, modified);
}
}
}