//version 8: import java.util.List; import java.util.Map; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = JacksonBuilderSingular.JacksonBuilderSingularBuilder.class) public class JacksonBuilderSingular { @JsonAnySetter private Map any; @JsonProperty("v_a_l_u_e_s") private List values; @JsonAnySetter private ImmutableMap guavaAny; @JsonProperty("guava_v_a_l_u_e_s") private ImmutableList guavaValues; @java.lang.SuppressWarnings("all") JacksonBuilderSingular(final Map any, final List values, final ImmutableMap guavaAny, final ImmutableList guavaValues) { this.any = any; this.values = values; this.guavaAny = guavaAny; this.guavaValues = guavaValues; } @java.lang.SuppressWarnings("all") @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "", buildMethodName = "build") public static class JacksonBuilderSingularBuilder { @java.lang.SuppressWarnings("all") private java.util.ArrayList any$key; @java.lang.SuppressWarnings("all") private java.util.ArrayList any$value; @java.lang.SuppressWarnings("all") private java.util.ArrayList values; @java.lang.SuppressWarnings("all") private com.google.common.collect.ImmutableMap.Builder guavaAny; @java.lang.SuppressWarnings("all") private com.google.common.collect.ImmutableList.Builder guavaValues; @java.lang.SuppressWarnings("all") JacksonBuilderSingularBuilder() { } @JsonAnySetter @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder any(final String anyKey, final Object anyValue) { if (this.any$key == null) { this.any$key = new java.util.ArrayList(); this.any$value = new java.util.ArrayList(); } this.any$key.add(anyKey); this.any$value.add(anyValue); return this; } @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder any(final java.util.Map any) { if (any == null) { throw new java.lang.NullPointerException("any cannot be null"); } if (this.any$key == null) { this.any$key = new java.util.ArrayList(); this.any$value = new java.util.ArrayList(); } for (final java.util.Map.Entry $lombokEntry : any.entrySet()) { this.any$key.add($lombokEntry.getKey()); this.any$value.add($lombokEntry.getValue()); } return this; } @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder clearAny() { if (this.any$key != null) { this.any$key.clear(); this.any$value.clear(); } return this; } @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder value(final String value) { if (this.values == null) this.values = new java.util.ArrayList(); this.values.add(value); return this; } @JsonProperty("v_a_l_u_e_s") @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder values(final java.util.Collection values) { if (values == null) { throw new java.lang.NullPointerException("values cannot be null"); } if (this.values == null) this.values = new java.util.ArrayList(); this.values.addAll(values); return this; } @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder clearValues() { if (this.values != null) this.values.clear(); return this; } @JsonAnySetter @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder guavaAny(final String key, final Object value) { if (this.guavaAny == null) this.guavaAny = com.google.common.collect.ImmutableMap.builder(); this.guavaAny.put(key, value); return this; } @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder guavaAny(final java.util.Map guavaAny) { if (guavaAny == null) { throw new java.lang.NullPointerException("guavaAny cannot be null"); } if (this.guavaAny == null) this.guavaAny = com.google.common.collect.ImmutableMap.builder(); this.guavaAny.putAll(guavaAny); return this; } @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder clearGuavaAny() { this.guavaAny = null; return this; } @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder guavaValue(final String guavaValue) { if (this.guavaValues == null) this.guavaValues = com.google.common.collect.ImmutableList.builder(); this.guavaValues.add(guavaValue); return this; } @JsonProperty("guava_v_a_l_u_e_s") @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder guavaValues(final java.lang.Iterable guavaValues) { if (guavaValues == null) { throw new java.lang.NullPointerException("guavaValues cannot be null"); } if (this.guavaValues == null) this.guavaValues = com.google.common.collect.ImmutableList.builder(); this.guavaValues.addAll(guavaValues); return this; } @java.lang.SuppressWarnings("all") public JacksonBuilderSingular.JacksonBuilderSingularBuilder clearGuavaValues() { this.guavaValues = null; return this; } @java.lang.SuppressWarnings("all") public JacksonBuilderSingular build() { java.util.Map any; switch (this.any$key == null ? 0 : this.any$key.size()) { case 0: any = java.util.Collections.emptyMap(); break; case 1: any = java.util.Collections.singletonMap(this.any$key.get(0), this.any$value.get(0)); break; default: any = new java.util.LinkedHashMap(this.any$key.size() < 1073741824 ? 1 + this.any$key.size() + (this.any$key.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); for (int $i = 0; $i < this.any$key.size(); $i++) any.put(this.any$key.get($i), (Object) this.any$value.get($i)); any = java.util.Collections.unmodifiableMap(any); } java.util.List values; switch (this.values == null ? 0 : this.values.size()) { case 0: values = java.util.Collections.emptyList(); break; case 1: values = java.util.Collections.singletonList(this.values.get(0)); break; default: values = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.values)); } com.google.common.collect.ImmutableMap guavaAny = this.guavaAny == null ? com.google.common.collect.ImmutableMap.of() : this.guavaAny.build(); com.google.common.collect.ImmutableList guavaValues = this.guavaValues == null ? com.google.common.collect.ImmutableList.of() : this.guavaValues.build(); return new JacksonBuilderSingular(any, values, guavaAny, guavaValues); } @java.lang.Override @java.lang.SuppressWarnings("all") public java.lang.String toString() { return "JacksonBuilderSingular.JacksonBuilderSingularBuilder(any$key=" + this.any$key + ", any$value=" + this.any$value + ", values=" + this.values + ", guavaAny=" + this.guavaAny + ", guavaValues=" + this.guavaValues + ")"; } } @java.lang.SuppressWarnings("all") public static JacksonBuilderSingular.JacksonBuilderSingularBuilder builder() { return new JacksonBuilderSingular.JacksonBuilderSingularBuilder(); } }