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

org.immutables.fixture.style.ImmutableDepluralize Maven / Gradle / Ivy

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

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultiset;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.primitives.Booleans;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.Arrays;
import java.util.Map;
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 Depluralize}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableDepluralize.builder()}. */ @Generated(from = "Depluralize", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableDepluralize implements Depluralize { private final ImmutableList feet; private final ImmutableSet boats; private final ImmutableMap people; private final ImmutableMultimap peopleRepublics; private final ImmutableList feetPeople; private final ImmutableMultiset goods; private ImmutableDepluralize( ImmutableList feet, ImmutableSet boats, ImmutableMap people, ImmutableMultimap peopleRepublics, ImmutableList feetPeople, ImmutableMultiset goods) { this.feet = feet; this.boats = boats; this.people = people; this.peopleRepublics = peopleRepublics; this.feetPeople = feetPeople; this.goods = goods; } /** * @return The value of the {@code feet} attribute */ @Override public ImmutableList feet() { return feet; } /** * @return The value of the {@code boats} attribute */ @Override public ImmutableSet boats() { return boats; } /** * @return The value of the {@code people} attribute */ @Override public ImmutableMap people() { return people; } /** * @return The value of the {@code peopleRepublics} attribute */ @Override public ImmutableMultimap peopleRepublics() { return peopleRepublics; } /** * @return The value of the {@code feetPeople} attribute */ @Override public ImmutableList feetPeople() { return feetPeople; } /** * @return The value of the {@code goods} attribute */ @Override public ImmutableMultiset goods() { return goods; } /** * Copy the current immutable object with elements that replace the content of {@link Depluralize#feet() feet}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withFeet(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableDepluralize(newValue, this.boats, this.people, this.peopleRepublics, this.feetPeople, this.goods); } /** * Copy the current immutable object with elements that replace the content of {@link Depluralize#feet() feet}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of feet elements to set * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withFeet(Iterable elements) { if (this.feet == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableDepluralize(newValue, this.boats, this.people, this.peopleRepublics, this.feetPeople, this.goods); } /** * Copy the current immutable object with elements that replace the content of {@link Depluralize#boats() boats}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withBoats(String... elements) { ImmutableSet newValue = ImmutableSet.copyOf(elements); return new ImmutableDepluralize(this.feet, newValue, this.people, this.peopleRepublics, this.feetPeople, this.goods); } /** * Copy the current immutable object with elements that replace the content of {@link Depluralize#boats() boats}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of boats elements to set * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withBoats(Iterable elements) { if (this.boats == elements) return this; ImmutableSet newValue = ImmutableSet.copyOf(elements); return new ImmutableDepluralize(this.feet, newValue, this.people, this.peopleRepublics, this.feetPeople, this.goods); } /** * Copy the current immutable object by replacing the {@link Depluralize#people() people} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the people map * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withPeople(Map entries) { if (this.people == entries) return this; ImmutableMap newValue = ImmutableMap.copyOf(entries); return new ImmutableDepluralize(this.feet, this.boats, newValue, this.peopleRepublics, this.feetPeople, this.goods); } /** * Copy the current immutable object by replacing the {@link Depluralize#peopleRepublics() peopleRepublics} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the peopleRepublics map * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withPeopleRepublics(Multimap entries) { if (this.peopleRepublics == entries) return this; ImmutableMultimap newValue = ImmutableMultimap.copyOf(entries); return new ImmutableDepluralize(this.feet, this.boats, this.people, newValue, this.feetPeople, this.goods); } /** * Copy the current immutable object with elements that replace the content of {@link Depluralize#feetPeople() feetPeople}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withFeetPeople(int... elements) { ImmutableList newValue = ImmutableList.copyOf(Ints.asList(elements)); return new ImmutableDepluralize(this.feet, this.boats, this.people, this.peopleRepublics, newValue, this.goods); } /** * Copy the current immutable object with elements that replace the content of {@link Depluralize#feetPeople() feetPeople}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of feetPeople elements to set * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withFeetPeople(Iterable elements) { if (this.feetPeople == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableDepluralize(this.feet, this.boats, this.people, this.peopleRepublics, newValue, this.goods); } /** * Copy the current immutable object with elements that replace the content of {@link Depluralize#goods() goods}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withGoods(boolean... elements) { ImmutableMultiset newValue = ImmutableMultiset.copyOf(Booleans.asList(elements)); return new ImmutableDepluralize(this.feet, this.boats, this.people, this.peopleRepublics, this.feetPeople, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link Depluralize#goods() goods}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of goods elements to set * @return A modified copy of {@code this} object */ public final ImmutableDepluralize withGoods(Iterable elements) { if (this.goods == elements) return this; ImmutableMultiset newValue = ImmutableMultiset.copyOf(elements); return new ImmutableDepluralize(this.feet, this.boats, this.people, this.peopleRepublics, this.feetPeople, newValue); } /** * This instance is equal to all instances of {@code ImmutableDepluralize} 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 ImmutableDepluralize && equalTo(0, (ImmutableDepluralize) another); } private boolean equalTo(int synthetic, ImmutableDepluralize another) { return feet.equals(another.feet) && boats.equals(another.boats) && people.equals(another.people) && peopleRepublics.equals(another.peopleRepublics) && feetPeople.equals(another.feetPeople) && goods.equals(another.goods); } /** * Computes a hash code from attributes: {@code feet}, {@code boats}, {@code people}, {@code peopleRepublics}, {@code feetPeople}, {@code goods}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + feet.hashCode(); h += (h << 5) + boats.hashCode(); h += (h << 5) + people.hashCode(); h += (h << 5) + peopleRepublics.hashCode(); h += (h << 5) + feetPeople.hashCode(); h += (h << 5) + goods.hashCode(); return h; } /** * Prints the immutable value {@code Depluralize} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("Depluralize") .omitNullValues() .add("feet", feet) .add("boats", boats) .add("people", people) .add("peopleRepublics", peopleRepublics) .add("feetPeople", feetPeople) .add("goods", goods) .toString(); } /** * Creates an immutable copy of a {@link Depluralize} 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 Depluralize instance */ public static ImmutableDepluralize copyOf(Depluralize instance) { if (instance instanceof ImmutableDepluralize) { return (ImmutableDepluralize) instance; } return ImmutableDepluralize.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableDepluralize ImmutableDepluralize}. *

   * ImmutableDepluralize.builder()
   *    .addFoot|addAllFeet(String) // {@link Depluralize#feet() feet} elements
   *    .addBoat|addAllBoats(String) // {@link Depluralize#boats() boats} elements
   *    .putPerson|putAllPeople(String => String) // {@link Depluralize#people() people} mappings
   *    .putPeopleRepublic|putAllPeopleRepublics(String => String) // {@link Depluralize#peopleRepublics() peopleRepublics} mappings
   *    .addFeetPerson|addAllFeetPeople(int) // {@link Depluralize#feetPeople() feetPeople} elements
   *    .addGoods|addAllGoods(boolean) // {@link Depluralize#goods() goods} elements
   *    .build();
   * 
* @return A new ImmutableDepluralize builder */ public static ImmutableDepluralize.Builder builder() { return new ImmutableDepluralize.Builder(); } /** * Builds instances of type {@link ImmutableDepluralize ImmutableDepluralize}. * 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 = "Depluralize", generator = "Immutables") @NotThreadSafe public static final class Builder { private ImmutableList.Builder feet = ImmutableList.builder(); private ImmutableSet.Builder boats = ImmutableSet.builder(); private ImmutableMap.Builder people = ImmutableMap.builder(); private ImmutableMultimap.Builder peopleRepublics = ImmutableMultimap.builder(); private ImmutableList.Builder feetPeople = ImmutableList.builder(); private ImmutableMultiset.Builder goods = ImmutableMultiset.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code Depluralize} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Depluralize instance) { Objects.requireNonNull(instance, "instance"); addAllFeet(instance.feet()); addAllBoats(instance.boats()); putAllPeople(instance.people()); putAllPeopleRepublics(instance.peopleRepublics()); addAllFeetPeople(instance.feetPeople()); addAllGoods(instance.goods()); return this; } /** * Adds one element to {@link Depluralize#feet() feet} list. * @param element A feet element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFoot(String element) { this.feet.add(element); return this; } /** * Adds elements to {@link Depluralize#feet() feet} list. * @param elements An array of feet elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFeet(String... elements) { this.feet.add(elements); return this; } /** * Sets or replaces all elements for {@link Depluralize#feet() feet} list. * @param elements An iterable of feet elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder feet(Iterable elements) { this.feet = ImmutableList.builder(); return addAllFeet(elements); } /** * Adds elements to {@link Depluralize#feet() feet} list. * @param elements An iterable of feet elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllFeet(Iterable elements) { this.feet.addAll(elements); return this; } /** * Adds one element to {@link Depluralize#boats() boats} set. * @param element A boats element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addBoat(String element) { this.boats.add(element); return this; } /** * Adds elements to {@link Depluralize#boats() boats} set. * @param elements An array of boats elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addBoats(String... elements) { this.boats.add(elements); return this; } /** * Sets or replaces all elements for {@link Depluralize#boats() boats} set. * @param elements An iterable of boats elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder boats(Iterable elements) { this.boats = ImmutableSet.builder(); return addAllBoats(elements); } /** * Adds elements to {@link Depluralize#boats() boats} set. * @param elements An iterable of boats elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllBoats(Iterable elements) { this.boats.addAll(elements); return this; } /** * Put one entry to the {@link Depluralize#people() people} map. * @param key The key in the people map * @param value The associated value in the people map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putPerson(String key, String value) { this.people.put(key, value); return this; } /** * Put one entry to the {@link Depluralize#people() people} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putPerson(Map.Entry entry) { this.people.put(entry); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link Depluralize#people() people} map. Nulls are not permitted * @param entries The entries that will be added to the people map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder people(Map entries) { this.people = ImmutableMap.builder(); return putAllPeople(entries); } /** * Put all mappings from the specified map as entries to {@link Depluralize#people() people} map. Nulls are not permitted * @param entries The entries that will be added to the people map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllPeople(Map entries) { this.people.putAll(entries); return this; } /** * Put all mappings from the specified key to values for {@link Depluralize#peopleRepublics() peopleRepublics} true. Nulls are not permitted * @param key The key for peopleRepublics * @param values The values for peopleRepublics * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putPeopleRepublics(String key, String... values) { this.peopleRepublics.putAll(key, Arrays.asList(values)); return this; } /** * Put all mappings from the specified key to values for {@link Depluralize#peopleRepublics() peopleRepublics} true. Nulls are not permitted * @param key The key for peopleRepublics * @param values The values for peopleRepublics * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllPeopleRepublics(String key, Iterable values) { this.peopleRepublics.putAll(key, values); return this; } /** * Put one entry to the {@link Depluralize#peopleRepublics() peopleRepublics} map. * @param key The key in the peopleRepublics map * @param value The associated value in the peopleRepublics map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putPeopleRepublic(String key, String value) { this.peopleRepublics.put(key, value); return this; } /** * Put one entry to the {@link Depluralize#peopleRepublics() peopleRepublics} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putPeopleRepublic(Map.Entry entry) { this.peopleRepublics.put(entry); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link Depluralize#peopleRepublics() peopleRepublics} map. Nulls are not permitted * @param entries The entries that will be added to the peopleRepublics map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder peopleRepublics(Multimap entries) { this.peopleRepublics = ImmutableMultimap.builder(); return putAllPeopleRepublics(entries); } /** * Put all mappings from the specified map as entries to {@link Depluralize#peopleRepublics() peopleRepublics} map. Nulls are not permitted * @param entries The entries that will be added to the peopleRepublics map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllPeopleRepublics(Multimap entries) { this.peopleRepublics.putAll(entries); return this; } /** * Adds one element to {@link Depluralize#feetPeople() feetPeople} list. * @param element A feetPeople element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFeetPerson(int element) { this.feetPeople.add(element); return this; } /** * Adds elements to {@link Depluralize#feetPeople() feetPeople} list. * @param elements An array of feetPeople elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFeetPeople(int... elements) { this.feetPeople.addAll(Ints.asList(elements)); return this; } /** * Sets or replaces all elements for {@link Depluralize#feetPeople() feetPeople} list. * @param elements An iterable of feetPeople elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder feetPeople(Iterable elements) { this.feetPeople = ImmutableList.builder(); return addAllFeetPeople(elements); } /** * Adds elements to {@link Depluralize#feetPeople() feetPeople} list. * @param elements An iterable of feetPeople elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllFeetPeople(Iterable elements) { this.feetPeople.addAll(elements); return this; } /** * Adds one element to {@link Depluralize#goods() goods} multiset. * @param element A goods element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addGoods(boolean element) { this.goods.add(element); return this; } /** * Adds elements to {@link Depluralize#goods() goods} multiset. * @param elements An array of goods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addGoods(boolean... elements) { this.goods.addAll(Booleans.asList(elements)); return this; } /** * Sets or replaces all elements for {@link Depluralize#goods() goods} multiset. * @param elements An iterable of goods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder goods(Iterable elements) { this.goods = ImmutableMultiset.builder(); return addAllGoods(elements); } /** * Adds elements to {@link Depluralize#goods() goods} multiset. * @param elements An iterable of goods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllGoods(Iterable elements) { this.goods.addAll(elements); return this; } /** * Builds a new {@link ImmutableDepluralize ImmutableDepluralize}. * @return An immutable instance of Depluralize * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableDepluralize build() { return new ImmutableDepluralize( feet.build(), boats.build(), people.build(), peopleRepublics.build(), feetPeople.build(), goods.build()); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy