All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.immutables.fixture.modifiable.ModifiableWithModifiableInterface Maven / Gradle / Ivy

There is a newer version: 2.10.1
Show newest version
package org.immutables.fixture.modifiable;

import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * A modifiable implementation of the {@link WithModifiableInterface WithModifiableInterface} type.
 * 

Use the {@link #create()} static factory methods to create new instances. * Use the {@link #toImmutable()} method to convert to canonical immutable instances. *

ModifiableWithModifiableInterface is not thread-safe * @see ImmutableWithModifiableInterface */ @Generated(from = "WithModifiableInterface", generator = "Modifiables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.Generated({"Modifiables.generator", "WithModifiableInterface"}) @NotThreadSafe final class ModifiableWithModifiableInterface extends WithModifiableInterface implements WithModifiableInterface.Modifiable { private final ArrayList prices = new ArrayList(); private final ArrayList pricesWithSalesTax = new ArrayList(); private ModifiableWithModifiableInterface() {} /** * Construct a modifiable instance of {@code WithModifiableInterface}. * @return A new modifiable instance */ public static ModifiableWithModifiableInterface create() { return new ModifiableWithModifiableInterface(); } /** * @return modifiable list {@code prices} */ @Override public final List getPrices() { return prices; } /** * @return modifiable list {@code pricesWithSalesTax} */ @Override final List getPricesWithSalesTax() { return pricesWithSalesTax; } /** * Clears the object by setting all attributes to their initial values. * @return {@code this} for use in a chained invocation */ @CanIgnoreReturnValue public ModifiableWithModifiableInterface clear() { prices.clear(); pricesWithSalesTax.clear(); return this; } /** * Fill this modifiable instance with attribute values from the provided {@link WithModifiableInterface} instance. * Regular attribute values will be overridden, i.e. replaced with ones of an instance. * Any of the instance's absent optional values will not be copied (will not override current values). * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} for use in a chained invocation */ public ModifiableWithModifiableInterface from(WithModifiableInterface instance) { Objects.requireNonNull(instance, "instance"); if (instance instanceof ModifiableWithModifiableInterface) { from((ModifiableWithModifiableInterface) instance); return this; } addAllPrices(instance.getPrices()); addAllPricesWithSalesTax(instance.getPricesWithSalesTax()); return this; } /** * Fill this modifiable instance with attribute values from the provided {@link WithModifiableInterface} instance. * Regular attribute values will be overridden, i.e. replaced with ones of an instance. * Any of the instance's absent optional values will not be copied (will not override current values). * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} for use in a chained invocation */ public ModifiableWithModifiableInterface from(ModifiableWithModifiableInterface instance) { Objects.requireNonNull(instance, "instance"); addAllPrices(instance.getPrices()); addAllPricesWithSalesTax(instance.getPricesWithSalesTax()); return this; } /** * Adds one element to {@link WithModifiableInterface#getPrices() prices} list. * @param element The prices element * @return {@code this} for use in a chained invocation */ @CanIgnoreReturnValue public ModifiableWithModifiableInterface addPrices(float element) { this.prices.add(element); return this; } /** * Adds elements to {@link WithModifiableInterface#getPrices() prices} list. * @param elements An array of prices elements * @return {@code this} for use in a chained invocation */ @CanIgnoreReturnValue public final ModifiableWithModifiableInterface addPrices(float... elements) { for (float e : elements) { addPrices(Objects.requireNonNull(e, "prices element")); } return this; } /** * Sets or replaces all elements for {@link WithModifiableInterface#getPrices() prices} list. * @param elements An iterable of prices elements * @return {@code this} for use in a chained invocation */ @CanIgnoreReturnValue public ModifiableWithModifiableInterface setPrices(Iterable elements) { this.prices.clear(); addAllPrices(elements); return this; } /** * Adds elements to {@link WithModifiableInterface#getPrices() prices} list. * @param elements An iterable of prices elements * @return {@code this} for use in a chained invocation */ @CanIgnoreReturnValue public ModifiableWithModifiableInterface addAllPrices(Iterable elements) { for (float e : elements) { addPrices(e); } return this; } /** * Adds one element to {@link WithModifiableInterface#getPricesWithSalesTax() pricesWithSalesTax} list. * @param element The pricesWithSalesTax element * @return {@code this} for use in a chained invocation */ @CanIgnoreReturnValue public ModifiableWithModifiableInterface addPricesWithSalesTax(float element) { this.pricesWithSalesTax.add(element); return this; } /** * Adds elements to {@link WithModifiableInterface#getPricesWithSalesTax() pricesWithSalesTax} list. * @param elements An array of pricesWithSalesTax elements * @return {@code this} for use in a chained invocation */ @CanIgnoreReturnValue public final ModifiableWithModifiableInterface addPricesWithSalesTax(float... elements) { for (float e : elements) { addPricesWithSalesTax(Objects.requireNonNull(e, "pricesWithSalesTax element")); } return this; } /** * Sets or replaces all elements for {@link WithModifiableInterface#getPricesWithSalesTax() pricesWithSalesTax} list. * @param elements An iterable of pricesWithSalesTax elements * @return {@code this} for use in a chained invocation */ @CanIgnoreReturnValue public ModifiableWithModifiableInterface setPricesWithSalesTax(Iterable elements) { this.pricesWithSalesTax.clear(); addAllPricesWithSalesTax(elements); return this; } /** * Adds elements to {@link WithModifiableInterface#getPricesWithSalesTax() pricesWithSalesTax} list. * @param elements An iterable of pricesWithSalesTax elements * @return {@code this} for use in a chained invocation */ @CanIgnoreReturnValue public ModifiableWithModifiableInterface addAllPricesWithSalesTax(Iterable elements) { for (float e : elements) { addPricesWithSalesTax(e); } return this; } /** * Returns {@code true} if all required attributes are set, indicating that the object is initialized. * @return {@code true} if set */ public final boolean isInitialized() { return true; } /** * Converts to {@link ImmutableWithModifiableInterface ImmutableWithModifiableInterface}. * @return An immutable instance of WithModifiableInterface */ public final ImmutableWithModifiableInterface toImmutable() { return ImmutableWithModifiableInterface.copyOf(this); } /** * This instance is equal to all instances of {@code ModifiableWithModifiableInterface} 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; if (!(another instanceof ModifiableWithModifiableInterface)) return false; ModifiableWithModifiableInterface other = (ModifiableWithModifiableInterface) another; return equalTo(other); } private boolean equalTo(ModifiableWithModifiableInterface another) { return prices.equals(another.prices) && pricesWithSalesTax.equals(another.pricesWithSalesTax); } /** * Computes a hash code from attributes: {@code prices}, {@code pricesWithSalesTax}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + prices.hashCode(); h += (h << 5) + pricesWithSalesTax.hashCode(); return h; } /** * Generates a string representation of this {@code WithModifiableInterface}. * If uninitialized, some attribute values may appear as question marks. * @return A string representation */ @Override public String toString() { return MoreObjects.toStringHelper("ModifiableWithModifiableInterface") .add("prices", getPrices()) .add("pricesWithSalesTax", getPricesWithSalesTax()) .toString(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy