nonimmutables.ImmutableHasUmlauts Maven / Gradle / Ivy
Show all versions of value-fixture Show documentation
package nonimmutables;
import java.lang.Object;
import java.lang.String;
import java.lang.Float;
import java.lang.Double;
/**
* Immutable implementation of {@link HasUmlauts}.
*
* Use the builder to create immutable instances:
* {@code ImmutableHasUmlauts.builder()}.
*/
@org.immutables.value.Generated(from = "HasUmlauts", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.ParametersAreNonnullByDefault
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@javax.annotation.concurrent.Immutable
@javax.annotation.CheckReturnValue
public final class ImmutableHasUmlauts implements nonimmutables.HasUmlauts {
private final int zahlungsempfänger;
private ImmutableHasUmlauts(int zahlungsempfänger) {
this.zahlungsempfänger = zahlungsempfänger;
}
/**
* @return The value of the {@code zahlungsempfänger} attribute
*/
@Override
public int getZahlungsempfänger() {
return zahlungsempfänger;
}
/**
* Copy the current immutable object by setting a value for the {@link HasUmlauts#getZahlungsempfänger() zahlungsempfänger} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for zahlungsempfänger
* @return A modified copy or the {@code this} object
*/
public final ImmutableHasUmlauts withZahlungsempfänger(int value) {
if (this.zahlungsempfänger == value) return this;
return new ImmutableHasUmlauts(value);
}
/**
* This instance is equal to all instances of {@code ImmutableHasUmlauts} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(@javax.annotation.Nullable Object another) {
if (this == another) return true;
return another instanceof ImmutableHasUmlauts
&& equalTo(0, (ImmutableHasUmlauts) another);
}
private boolean equalTo(int synthetic, ImmutableHasUmlauts another) {
return zahlungsempfänger == another.zahlungsempfänger;
}
/**
* Computes a hash code from attributes: {@code zahlungsempfänger}.
* @return hashCode value
*/
@Override
public int hashCode() {
@com.google.errorprone.annotations.Var int h = 5381;
h += (h << 5) + zahlungsempfänger;
return h;
}
/**
* Prints the immutable value {@code HasUmlauts} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return com.google.common.base.MoreObjects.toStringHelper("HasUmlauts")
.omitNullValues()
.add("zahlungsempfänger", zahlungsempfänger)
.toString();
}
/**
* Creates an immutable copy of a {@link HasUmlauts} 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 HasUmlauts instance
*/
public static ImmutableHasUmlauts copyOf(HasUmlauts instance) {
if (instance instanceof ImmutableHasUmlauts) {
return (ImmutableHasUmlauts) instance;
}
return ImmutableHasUmlauts.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableHasUmlauts ImmutableHasUmlauts}.
*
* ImmutableHasUmlauts.builder()
* .zahlungsempfänger(int) // required {@link HasUmlauts#getZahlungsempfänger() zahlungsempfänger}
* .build();
*
* @return A new ImmutableHasUmlauts builder
*/
public static ImmutableHasUmlauts.Builder builder() {
return new ImmutableHasUmlauts.Builder();
}
/**
* Builds instances of type {@link ImmutableHasUmlauts ImmutableHasUmlauts}.
* 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.
*/
@org.immutables.value.Generated(from = "HasUmlauts", generator = "Immutables")
@javax.annotation.concurrent.NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_ZAHLUNGSEMPFäNGER = 0x1L;
private long initBits = 0x1L;
private int zahlungsempfänger;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code HasUmlauts} 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
*/
@com.google.errorprone.annotations.CanIgnoreReturnValue
public final Builder from(HasUmlauts instance) {
java.util.Objects.requireNonNull(instance, "instance");
this.zahlungsempfänger(instance.getZahlungsempfänger());
return this;
}
/**
* Initializes the value for the {@link HasUmlauts#getZahlungsempfänger() zahlungsempfänger} attribute.
* @param zahlungsempfänger The value for zahlungsempfänger
* @return {@code this} builder for use in a chained invocation
*/
@com.google.errorprone.annotations.CanIgnoreReturnValue
public final Builder zahlungsempfänger(int zahlungsempfänger) {
this.zahlungsempfänger = zahlungsempfänger;
initBits &= ~INIT_BIT_ZAHLUNGSEMPFäNGER;
return this;
}
/**
* Builds a new {@link ImmutableHasUmlauts ImmutableHasUmlauts}.
* @return An immutable instance of HasUmlauts
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableHasUmlauts build() {
if (initBits != 0) {
throw new java.lang.IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableHasUmlauts(zahlungsempfänger);
}
private String formatRequiredAttributesMessage() {
java.util.List attributes = new java.util.ArrayList<>();
if ((initBits & INIT_BIT_ZAHLUNGSEMPFäNGER) != 0) attributes.add("zahlungsempfänger");
return "Cannot build HasUmlauts, some of required attributes are not set " + attributes;
}
}
}