org.immutables.fixture.jackson.ImmutableNoBuilderDeserialize Maven / Gradle / Ivy
package org.immutables.fixture.jackson;
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.common.collect.ImmutableList;
import java.util.List;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
/**
* Immutable implementation of {@link NoBuilderDeserialize}.
*
* Use the static factory method to get the default singleton instance:
* {@code ImmutableNoBuilderDeserialize.instance()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "NoBuilderDeserialize"})
@Immutable
public final class ImmutableNoBuilderDeserialize extends NoBuilderDeserialize {
private final ImmutableList prop;
private ImmutableNoBuilderDeserialize() {
this.prop = ImmutableList.of();
}
private ImmutableNoBuilderDeserialize(ImmutableList prop) {
this.prop = prop;
}
/**
* @return The value of the {@code prop} attribute
*/
@JsonProperty
@Override
public ImmutableList prop() {
return prop;
}
/**
* Copy the current immutable object with elements that replace the content of {@link NoBuilderDeserialize#prop() prop}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableNoBuilderDeserialize withProp(String... elements) {
ImmutableList newValue = ImmutableList.copyOf(elements);
return validate(new ImmutableNoBuilderDeserialize(newValue));
}
/**
* Copy the current immutable object with elements that replace the content of {@link NoBuilderDeserialize#prop() prop}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of prop elements to set
* @return A modified copy of {@code this} object
*/
public final ImmutableNoBuilderDeserialize withProp(Iterable elements) {
if (this.prop == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return validate(new ImmutableNoBuilderDeserialize(newValue));
}
/**
* This instance is equal to all instances of {@code ImmutableNoBuilderDeserialize} 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 ImmutableNoBuilderDeserialize
&& equalTo((ImmutableNoBuilderDeserialize) another);
}
private boolean equalTo(ImmutableNoBuilderDeserialize another) {
return prop.equals(another.prop);
}
/**
* Computes a hash code from attributes: {@code prop}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + prop.hashCode();
return h;
}
/**
* Prints the immutable value {@code NoBuilderDeserialize} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("NoBuilderDeserialize")
.omitNullValues()
.add("prop", prop)
.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
*/
@Deprecated
@JsonDeserialize
static final class Json extends NoBuilderDeserialize {
List prop = ImmutableList.of();
@JsonProperty
public void setProp(List prop) {
this.prop = prop;
}
@Override
public List prop() { 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
static ImmutableNoBuilderDeserialize fromJson(Json json) {
ImmutableNoBuilderDeserialize instance = ImmutableNoBuilderDeserialize.instance();
if (json.prop != null) {
instance = instance.withProp(json.prop);
}
return instance;
}
private static final ImmutableNoBuilderDeserialize INSTANCE = validate(new ImmutableNoBuilderDeserialize());
/**
* Returns the default immutable singleton value of {@code NoBuilderDeserialize}
* @return An immutable instance of NoBuilderDeserialize
*/
public static ImmutableNoBuilderDeserialize instance() {
return INSTANCE;
}
private static ImmutableNoBuilderDeserialize validate(ImmutableNoBuilderDeserialize instance) {
return INSTANCE != null && INSTANCE.equalTo(instance) ? INSTANCE : instance;
}
}