io.norberg.automatter.example.GenericFoobarBuilder Maven / Gradle / Ivy
package io.norberg.automatter.example;
import io.norberg.automatter.AutoMatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
@Generated("io.norberg.automatter.processor.AutoMatterProcessor")
final class GenericFoobarBuilder {
private T foo;
private List bar;
private Map bazs;
public GenericFoobarBuilder() {
}
private GenericFoobarBuilder(GenericFoobar extends T> v) {
this.foo = v.foo();
List extends T> _bar = v.bar();
this.bar = (_bar == null) ? null : new ArrayList(_bar);
Map extends String, ? extends T> _bazs = v.bazs();
this.bazs = (_bazs == null) ? null : new HashMap(_bazs);
}
private GenericFoobarBuilder(GenericFoobarBuilder extends T> v) {
this.foo = v.foo;
this.bar = (v.bar == null) ? null : new ArrayList(v.bar);
this.bazs = (v.bazs == null) ? null : new HashMap(v.bazs);
}
public T foo() {
return foo;
}
public GenericFoobarBuilder foo(T foo) {
if (foo == null) {
throw new NullPointerException("foo");
}
this.foo = foo;
return this;
}
public List bar() {
if (this.bar == null) {
this.bar = new ArrayList();
}
return bar;
}
public GenericFoobarBuilder bar(List extends T> bar) {
return bar((Collection extends T>) bar);
}
public GenericFoobarBuilder bar(Collection extends T> bar) {
if (bar == null) {
throw new NullPointerException("bar");
}
for (T item : bar) {
if (item == null) {
throw new NullPointerException("bar: null item");
}
}
this.bar = new ArrayList(bar);
return this;
}
public GenericFoobarBuilder bar(Iterable extends T> bar) {
if (bar == null) {
throw new NullPointerException("bar");
}
if (bar instanceof Collection) {
return bar((Collection extends T>) bar);
}
return bar(bar.iterator());
}
public GenericFoobarBuilder bar(Iterator extends T> bar) {
if (bar == null) {
throw new NullPointerException("bar");
}
this.bar = new ArrayList();
while (bar.hasNext()) {
T item = bar.next();
if (item == null) {
throw new NullPointerException("bar: null item");
}
this.bar.add(item);
}
return this;
}
@SafeVarargs
public final GenericFoobarBuilder bar(T... bar) {
if (bar == null) {
throw new NullPointerException("bar");
}
return bar(Arrays.asList(bar));
}
public Map bazs() {
if (this.bazs == null) {
this.bazs = new HashMap();
}
return bazs;
}
public GenericFoobarBuilder bazs(Map extends String, ? extends T> bazs) {
if (bazs == null) {
throw new NullPointerException("bazs");
}
for (Map.Entry extends String, ? extends T> entry : bazs.entrySet()) {
if (entry.getKey() == null) {
throw new NullPointerException("bazs: null key");
}
if (entry.getValue() == null) {
throw new NullPointerException("bazs: null value");
}
}
this.bazs = new HashMap(bazs);
return this;
}
public GenericFoobarBuilder bazs(String k1, T v1) {
if (k1 == null) {
throw new NullPointerException("bazs: k1");
}
if (v1 == null) {
throw new NullPointerException("bazs: v1");
}
bazs = new HashMap();
bazs.put(k1, v1);
return this;
}
public GenericFoobarBuilder bazs(String k1, T v1, String k2, T v2) {
bazs(k1, v1);
if (k2 == null) {
throw new NullPointerException("bazs: k2");
}
if (v2 == null) {
throw new NullPointerException("bazs: v2");
}
bazs.put(k2, v2);
return this;
}
public GenericFoobarBuilder bazs(String k1, T v1, String k2, T v2, String k3, T v3) {
bazs(k1, v1, k2, v2);
if (k3 == null) {
throw new NullPointerException("bazs: k3");
}
if (v3 == null) {
throw new NullPointerException("bazs: v3");
}
bazs.put(k3, v3);
return this;
}
public GenericFoobarBuilder bazs(String k1, T v1, String k2, T v2, String k3, T v3, String k4, T v4) {
bazs(k1, v1, k2, v2, k3, v3);
if (k4 == null) {
throw new NullPointerException("bazs: k4");
}
if (v4 == null) {
throw new NullPointerException("bazs: v4");
}
bazs.put(k4, v4);
return this;
}
public GenericFoobarBuilder bazs(String k1, T v1, String k2, T v2, String k3, T v3, String k4, T v4, String k5, T v5) {
bazs(k1, v1, k2, v2, k3, v3, k4, v4);
if (k5 == null) {
throw new NullPointerException("bazs: k5");
}
if (v5 == null) {
throw new NullPointerException("bazs: v5");
}
bazs.put(k5, v5);
return this;
}
public GenericFoobarBuilder putBaz(String key, T value) {
if (key == null) {
throw new NullPointerException("baz: key");
}
if (value == null) {
throw new NullPointerException("baz: value");
}
if (this.bazs == null) {
this.bazs = new HashMap();
}
bazs.put(key, value);
return this;
}
public GenericFoobar build() {
List _bar = (bar != null) ? Collections.unmodifiableList(new ArrayList(bar)) : Collections.emptyList();
Map _bazs = (bazs != null) ? Collections.unmodifiableMap(new HashMap(bazs)) : Collections.emptyMap();
return new Value(foo, _bar, _bazs);
}
public static GenericFoobarBuilder from(GenericFoobar extends T> v) {
return new GenericFoobarBuilder(v);
}
public static GenericFoobarBuilder from(GenericFoobarBuilder extends T> v) {
return new GenericFoobarBuilder(v);
}
private static final class Value implements GenericFoobar {
private final T foo;
private final List bar;
private final Map bazs;
private Value(@AutoMatter.Field("foo") T foo, @AutoMatter.Field("bar") List bar, @AutoMatter.Field("bazs") Map bazs) {
if (foo == null) {
throw new NullPointerException("foo");
}
this.foo = foo;
this.bar = (bar != null) ? bar : Collections.emptyList();
this.bazs = (bazs != null) ? bazs : Collections.emptyMap();
}
@AutoMatter.Field
@Override
public T foo() {
return foo;
}
@AutoMatter.Field
@Override
public List bar() {
return bar;
}
@AutoMatter.Field
@Override
public Map bazs() {
return bazs;
}
public GenericFoobarBuilder builder() {
return new GenericFoobarBuilder(this);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof GenericFoobar)) {
return false;
}
final GenericFoobar> that = (GenericFoobar>) o;
if (foo != null ? !foo.equals(that.foo()) : that.foo() != null) {
return false;
}
if (bar != null ? !bar.equals(that.bar()) : that.bar() != null) {
return false;
}
if (bazs != null ? !bazs.equals(that.bazs()) : that.bazs() != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (foo != null ? foo.hashCode() : 0);
result = 31 * result + (bar != null ? bar.hashCode() : 0);
result = 31 * result + (bazs != null ? bazs.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "GenericFoobar{" +
"foo=" + foo +
", bar=" + bar +
", bazs=" + bazs +
'}';
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy