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

cn.zenliu.units.codegen.model.Models Maven / Gradle / Ivy

The newest version!
package cn.zenliu.units.codegen.model;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
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;

/**
 * {@code Models} contains immutable implementation classes generated from
 * abstract value types defined as nested inside {@link Model}.
 * @see Models.Pkg
 * @see Models.RawType
 * @see Models.EnumType
 * @see Models.RecordType
 * @see Models.ArrayType
 * @see Models.AnnotationType
 * @see Models.Method
 * @see Models.Parameter
 * @see Models.Field
 * @see Models.GenericType
 * @see Models.ParameterizedType
 * @see Models.TypeVar
 * @see Models.TypeParam
 * @see Models.Annotation
 * @see Models.AnnotatedValue
 * @see Models.Enum
 */
@Generated(from = "Model", generator = "Immutables")
@SuppressWarnings({"unused", "all"})
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
public final class Models {
  private Models() {}

  /**
   * Immutable implementation of {@link Model.Pkg}.
   * 

* Use the builder to create immutable instances: * {@code Models.Pkg.builder()}. * Use the static factory method to create immutable instances: * {@code Models.Pkg.of()}. */ @Generated(from = "Model.Pkg", generator = "Immutables") @Immutable @CheckReturnValue public static final class Pkg implements Model.Pkg { private final List annotations; private final String name; private Pkg(String name) { this.name = Objects.requireNonNull(name, "name"); this.annotations = Collections.emptyList(); } private Pkg(List annotations, String name) { this.annotations = annotations; this.name = name; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * Copy the current immutable object with elements that replace the content of {@link Model.Pkg#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.Pkg withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.Pkg(newValue, this.name); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Pkg#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.Pkg withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.Pkg(newValue, this.name); } /** * Copy the current immutable object by setting a value for the {@link Model.Pkg#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.Pkg withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.Pkg(this.annotations, newValue); } /** * This instance is equal to all instances of {@code Pkg} 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 Models.Pkg && equalTo(0, (Models.Pkg) another); } private boolean equalTo(int synthetic, Models.Pkg another) { return annotations.equals(another.annotations) && name.equals(another.name); } /** * Computes a hash code from attributes: {@code annotations}, {@code name}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + name.hashCode(); return h; } /** * Prints the immutable value {@code Pkg} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "Pkg{" + "annotations=" + annotations + ", name=" + name + "}"; } /** * Construct a new immutable {@code Pkg} instance. * @param name The value for the {@code name} attribute * @return An immutable Pkg instance */ public static Models.Pkg of(String name) { return new Models.Pkg(name); } /** * Creates an immutable copy of a {@link Model.Pkg} 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 Pkg instance */ public static Models.Pkg copyOf(Model.Pkg instance) { if (instance instanceof Models.Pkg) { return (Models.Pkg) instance; } return Models.Pkg.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.Pkg Pkg}. *

     * Models.Pkg.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.Pkg#annotations() annotations} elements
     *    .name(String) // required {@link Model.Pkg#name() name}
     *    .build();
     * 
* @return A new Pkg builder */ public static Models.Pkg.Builder builder() { return new Models.Pkg.Builder(); } /** * Builds instances of type {@link Models.Pkg Pkg}. * 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 = "Model.Pkg", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_NAME = 0x1L; private long initBits = 0x1L; private List annotations = new ArrayList(); private @Nullable String name; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Pkg} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Pkg instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x2L) == 0) { name(instance.name()); bits |= 0x2L; } } if (object instanceof Model.Pkg) { Model.Pkg instance = (Model.Pkg) object; if ((bits & 0x2L) == 0) { name(instance.name()); bits |= 0x2L; } if ((bits & 0x1L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x1L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x1L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x1L; } } } /** * Adds one element to {@link Model.Pkg#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.Pkg#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.Pkg#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.Pkg#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.Pkg#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the value for the {@link Model.Pkg#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Builds a new {@link Models.Pkg Pkg}. * @return An immutable instance of Pkg * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.Pkg build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.Pkg(createUnmodifiableList(true, annotations), name); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build Pkg, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.RawType}. *

* Use the builder to create immutable instances: * {@code Models.RawType.builder()}. * Use the static factory method to create immutable instances: * {@code Models.RawType.of()}. */ @Generated(from = "Model.RawType", generator = "Immutables") @Immutable @CheckReturnValue public static final class RawType implements Model.RawType { private final List annotations; private final @Nullable Model.Type declaringType; private final List declaredTypes; private final List fields; private final List methods; private final List implemented; private final @Nullable Model.Type superType; private final int modifier; private final String name; private final Models.Pkg pkg; private RawType(int modifier, String name, Model.Pkg pkg) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.pkg = Models.Pkg.copyOf(pkg); this.annotations = Collections.emptyList(); this.declaringType = null; this.declaredTypes = Collections.emptyList(); this.fields = Collections.emptyList(); this.methods = Collections.emptyList(); this.implemented = Collections.emptyList(); this.superType = null; } private RawType( List annotations, @Nullable Model.Type declaringType, List declaredTypes, List fields, List methods, List implemented, @Nullable Model.Type superType, int modifier, String name, Models.Pkg pkg) { this.annotations = annotations; this.declaringType = declaringType; this.declaredTypes = declaredTypes; this.fields = fields; this.methods = methods; this.implemented = implemented; this.superType = superType; this.modifier = modifier; this.name = name; this.pkg = pkg; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code declaredTypes} attribute */ @Override public List declaredTypes() { return declaredTypes; } /** * @return The value of the {@code fields} attribute */ @Override public List fields() { return fields; } /** * @return The value of the {@code methods} attribute */ @Override public List methods() { return methods; } /** * @return The value of the {@code implemented} attribute */ @Override public List implemented() { return implemented; } /** * @return The value of the {@code superType} attribute */ @Override public Optional superType() { return Optional.ofNullable(superType); } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code pkg} attribute */ @Override public Models.Pkg pkg() { return pkg; } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RawType( newValue, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RawType( newValue, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.RawType#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.RawType withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.RawType( this.annotations, newValue, this.declaredTypes, this.fields, this.methods, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting an optional value for the {@link Model.RawType#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.RawType withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.RawType( this.annotations, value, this.declaredTypes, this.fields, this.methods, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#declaredTypes() declaredTypes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withDeclaredTypes(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RawType( this.annotations, this.declaringType, newValue, this.fields, this.methods, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#declaredTypes() declaredTypes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of declaredTypes elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withDeclaredTypes(Iterable elements) { if (this.declaredTypes == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RawType( this.annotations, this.declaringType, newValue, this.fields, this.methods, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#fields() fields}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withFields(Model.Field... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.methods, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#fields() fields}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of fields elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withFields(Iterable elements) { if (this.fields == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.methods, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#methods() methods}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withMethods(Model.Method... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, this.fields, newValue, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#methods() methods}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of methods elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withMethods(Iterable elements) { if (this.methods == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, this.fields, newValue, this.implemented, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#implemented() implemented}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withImplemented(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, newValue, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RawType#implemented() implemented}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of implemented elements to set * @return A modified copy of {@code this} object */ public final Models.RawType withImplemented(Iterable elements) { if (this.implemented == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, newValue, this.superType, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.RawType#superType() superType} attribute. * @param value The value for superType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.RawType withSuperType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.superType == newValue) return this; return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, newValue, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting an optional value for the {@link Model.RawType#superType() superType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for superType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.RawType withSuperType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.superType == value) return this; return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, value, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.RawType#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.RawType withModifier(int value) { if (this.modifier == value) return this; return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.superType, value, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.RawType#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.RawType withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.superType, this.modifier, newValue, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.RawType#pkg() pkg} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for pkg * @return A modified copy of the {@code this} object */ public final Models.RawType withPkg(Model.Pkg value) { if (this.pkg == value) return this; Models.Pkg newValue = Models.Pkg.copyOf(value); return new Models.RawType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.superType, this.modifier, this.name, newValue); } /** * This instance is equal to all instances of {@code RawType} 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 Models.RawType && equalTo(0, (Models.RawType) another); } private boolean equalTo(int synthetic, Models.RawType another) { return annotations.equals(another.annotations) && Objects.equals(declaringType, another.declaringType) && declaredTypes.equals(another.declaredTypes) && fields.equals(another.fields) && methods.equals(another.methods) && implemented.equals(another.implemented) && Objects.equals(superType, another.superType) && modifier == another.modifier && name.equals(another.name) && pkg.equals(another.pkg); } /** * Computes a hash code from attributes: {@code annotations}, {@code declaringType}, {@code declaredTypes}, {@code fields}, {@code methods}, {@code implemented}, {@code superType}, {@code modifier}, {@code name}, {@code pkg}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + declaredTypes.hashCode(); h += (h << 5) + fields.hashCode(); h += (h << 5) + methods.hashCode(); h += (h << 5) + implemented.hashCode(); h += (h << 5) + Objects.hashCode(superType); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); h += (h << 5) + pkg.hashCode(); return h; } /** * Prints the immutable value {@code RawType} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("RawType{"); builder.append("annotations=").append(annotations); if (declaringType != null) { builder.append(", "); builder.append("declaringType=").append(declaringType); } builder.append(", "); builder.append("declaredTypes=").append(declaredTypes); builder.append(", "); builder.append("fields=").append(fields); builder.append(", "); builder.append("methods=").append(methods); builder.append(", "); builder.append("implemented=").append(implemented); if (superType != null) { builder.append(", "); builder.append("superType=").append(superType); } builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); builder.append(", "); builder.append("pkg=").append(pkg); return builder.append("}").toString(); } /** * Construct a new immutable {@code RawType} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @param pkg The value for the {@code pkg} attribute * @return An immutable RawType instance */ public static Models.RawType of(int modifier, String name, Model.Pkg pkg) { return new Models.RawType(modifier, name, pkg); } /** * Creates an immutable copy of a {@link Model.RawType} 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 RawType instance */ public static Models.RawType copyOf(Model.RawType instance) { if (instance instanceof Models.RawType) { return (Models.RawType) instance; } return Models.RawType.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.RawType RawType}. *

     * Models.RawType.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.RawType#annotations() annotations} elements
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.RawType#declaringType() declaringType}
     *    .addDeclaredTypes|addAllDeclaredTypes(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.RawType#declaredTypes() declaredTypes} elements
     *    .addFields|addAllFields(cn.zenliu.units.codegen.model.Model.Field) // {@link Model.RawType#fields() fields} elements
     *    .addMethods|addAllMethods(cn.zenliu.units.codegen.model.Model.Method) // {@link Model.RawType#methods() methods} elements
     *    .addImplemented|addAllImplemented(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.RawType#implemented() implemented} elements
     *    .superType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.RawType#superType() superType}
     *    .modifier(int) // required {@link Model.RawType#modifier() modifier}
     *    .name(String) // required {@link Model.RawType#name() name}
     *    .pkg(cn.zenliu.units.codegen.model.Model.Pkg) // required {@link Model.RawType#pkg() pkg}
     *    .build();
     * 
* @return A new RawType builder */ public static Models.RawType.Builder builder() { return new Models.RawType.Builder(); } /** * Builds instances of type {@link Models.RawType RawType}. * 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 = "Model.RawType", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private static final long INIT_BIT_PKG = 0x4L; private long initBits = 0x7L; private List annotations = new ArrayList(); private @Nullable Model.Type declaringType; private List declaredTypes = new ArrayList(); private List fields = new ArrayList(); private List methods = new ArrayList(); private List implemented = new ArrayList(); private @Nullable Model.Type superType; private int modifier; private @Nullable String name; private @Nullable Model.Pkg pkg; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.RawType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.RawType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Extended} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Extended instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Implements} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Implements instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaredTypes} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaredTypes instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Type} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Type instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Package} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Package instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.MethodHolder} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.MethodHolder instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.FieldHolder} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.FieldHolder instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.RawType) { Model.RawType instance = (Model.RawType) object; if ((bits & 0x1L) == 0) { addAllMethods(instance.methods()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } if ((bits & 0x20L) == 0) { addAllImplemented(instance.implemented()); bits |= 0x20L; } if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x80L) == 0) { addAllFields(instance.fields()); bits |= 0x80L; } if ((bits & 0x100L) == 0) { Optional superTypeOptional = instance.superType(); if (superTypeOptional.isPresent()) { superType(superTypeOptional); } bits |= 0x100L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x200L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x200L; } } if (object instanceof Model.With.Extended) { Model.With.Extended instance = (Model.With.Extended) object; if ((bits & 0x100L) == 0) { Optional superTypeOptional = instance.superType(); if (superTypeOptional.isPresent()) { superType(superTypeOptional); } bits |= 0x100L; } } if (object instanceof Model.With.Implements) { Model.With.Implements instance = (Model.With.Implements) object; if ((bits & 0x20L) == 0) { addAllImplemented(instance.implemented()); bits |= 0x20L; } } if (object instanceof Model.With.DeclaredTypes) { Model.With.DeclaredTypes instance = (Model.With.DeclaredTypes) object; if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } } if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x200L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x200L; } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } } if (object instanceof Model.Type) { Model.Type instance = (Model.Type) object; if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x200L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x200L; } if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } } if (object instanceof Model.With.Package) { Model.With.Package instance = (Model.With.Package) object; if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } } if (object instanceof Model.With.MethodHolder) { Model.With.MethodHolder instance = (Model.With.MethodHolder) object; if ((bits & 0x1L) == 0) { addAllMethods(instance.methods()); bits |= 0x1L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } } if (object instanceof Model.With.FieldHolder) { Model.With.FieldHolder instance = (Model.With.FieldHolder) object; if ((bits & 0x80L) == 0) { addAllFields(instance.fields()); bits |= 0x80L; } } } /** * Adds one element to {@link Model.RawType#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.RawType#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.RawType#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.RawType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.RawType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the optional value {@link Model.RawType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.RawType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Adds one element to {@link Model.RawType#declaredTypes() declaredTypes} list. * @param element A declaredTypes element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type element) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); return this; } /** * Adds elements to {@link Model.RawType#declaredTypes() declaredTypes} list. * @param elements An array of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type... elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Sets or replaces all elements for {@link Model.RawType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaredTypes(Iterable elements) { this.declaredTypes.clear(); return addAllDeclaredTypes(elements); } /** * Adds elements to {@link Model.RawType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllDeclaredTypes(Iterable elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Adds one element to {@link Model.RawType#fields() fields} list. * @param element A fields element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFields(Model.Field element) { element = Models.Field.copyOf(element); this.fields.add(Objects.requireNonNull(element, "fields element")); return this; } /** * Constructs and adds an element for the {@link Model.RawType#fields() fields} list. * @param modifier The value for {@code fields.modifier} * @param name The value for {@code fields.name} * @param type The value for {@code fields.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addFields(int modifier, String name, Model.Type type) { return addFields(Models.Field.of(modifier, name, type)); } /** * Adds elements to {@link Model.RawType#fields() fields} list. * @param elements An array of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFields(Model.Field... elements) { for (Model.Field element : elements) { element = Models.Field.copyOf(element); this.fields.add(Objects.requireNonNull(element, "fields element")); } return this; } /** * Sets or replaces all elements for {@link Model.RawType#fields() fields} list. * @param elements An iterable of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder fields(Iterable elements) { this.fields.clear(); return addAllFields(elements); } /** * Adds elements to {@link Model.RawType#fields() fields} list. * @param elements An iterable of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllFields(Iterable elements) { for (Model.Field element : elements) { element = Models.Field.copyOf(element); this.fields.add(Objects.requireNonNull(element, "fields element")); } return this; } /** * Adds one element to {@link Model.RawType#methods() methods} list. * @param element A methods element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMethods(Model.Method element) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); return this; } /** * Constructs and adds an element for the {@link Model.RawType#methods() methods} list. * @param modifier The value for {@code methods.modifier} * @param name The value for {@code methods.name} * @return {@code this} builder for use in a chained invocation */ public final Builder addMethods(int modifier, String name) { return addMethods(Models.Method.of(modifier, name)); } /** * Adds elements to {@link Model.RawType#methods() methods} list. * @param elements An array of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMethods(Model.Method... elements) { for (Model.Method element : elements) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); } return this; } /** * Sets or replaces all elements for {@link Model.RawType#methods() methods} list. * @param elements An iterable of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder methods(Iterable elements) { this.methods.clear(); return addAllMethods(elements); } /** * Adds elements to {@link Model.RawType#methods() methods} list. * @param elements An iterable of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllMethods(Iterable elements) { for (Model.Method element : elements) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); } return this; } /** * Adds one element to {@link Model.RawType#implemented() implemented} list. * @param element A implemented element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addImplemented(Model.Type element) { this.implemented.add(Objects.requireNonNull(element, "implemented element")); return this; } /** * Adds elements to {@link Model.RawType#implemented() implemented} list. * @param elements An array of implemented elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addImplemented(Model.Type... elements) { for (Model.Type element : elements) { this.implemented.add(Objects.requireNonNull(element, "implemented element")); } return this; } /** * Sets or replaces all elements for {@link Model.RawType#implemented() implemented} list. * @param elements An iterable of implemented elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder implemented(Iterable elements) { this.implemented.clear(); return addAllImplemented(elements); } /** * Adds elements to {@link Model.RawType#implemented() implemented} list. * @param elements An iterable of implemented elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllImplemented(Iterable elements) { for (Model.Type element : elements) { this.implemented.add(Objects.requireNonNull(element, "implemented element")); } return this; } /** * Initializes the optional value {@link Model.RawType#superType() superType} to superType. * @param superType The value for superType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder superType(@Nullable Model.Type superType) { this.superType = superType; return this; } /** * Initializes the optional value {@link Model.RawType#superType() superType} to superType. * @param superType The value for superType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder superType(Optional superType) { this.superType = superType.orElse(null); return this; } /** * Initializes the value for the {@link Model.RawType#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.RawType#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Constructs and initializes the value for the {@link Model.RawType#pkg() pkg} attribute. * @param name The value for {@code pkg.name} * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(String name) { return pkg(Models.Pkg.of(name)); } /** * Initializes the value for the {@link Model.RawType#pkg() pkg} attribute. * @param pkg The value for pkg * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(Model.Pkg pkg) { this.pkg = Models.Pkg.copyOf(pkg); initBits &= ~INIT_BIT_PKG; return this; } /** * Builds a new {@link Models.RawType RawType}. * @return An immutable instance of RawType * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.RawType build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.RawType( createUnmodifiableList(true, annotations), declaringType, createUnmodifiableList(true, declaredTypes), createUnmodifiableList(true, fields), createUnmodifiableList(true, methods), createUnmodifiableList(true, implemented), superType, modifier, name, Models.Pkg.copyOf(pkg)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_PKG) != 0) attributes.add("pkg"); return "Cannot build RawType, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.EnumType}. *

* Use the builder to create immutable instances: * {@code Models.EnumType.builder()}. * Use the static factory method to create immutable instances: * {@code Models.EnumType.of()}. */ @Generated(from = "Model.EnumType", generator = "Immutables") @Immutable @CheckReturnValue public static final class EnumType implements Model.EnumType { private final List annotations; private final @Nullable Model.Type declaringType; private final List declaredTypes; private final List fields; private final List methods; private final List implemented; private final int modifier; private final String name; private final Models.Pkg pkg; private final List names; private EnumType(int modifier, String name, Model.Pkg pkg) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.pkg = Models.Pkg.copyOf(pkg); this.annotations = Collections.emptyList(); this.declaringType = null; this.declaredTypes = Collections.emptyList(); this.fields = Collections.emptyList(); this.methods = Collections.emptyList(); this.implemented = Collections.emptyList(); this.names = Collections.emptyList(); } private EnumType( List annotations, @Nullable Model.Type declaringType, List declaredTypes, List fields, List methods, List implemented, int modifier, String name, Models.Pkg pkg, List names) { this.annotations = annotations; this.declaringType = declaringType; this.declaredTypes = declaredTypes; this.fields = fields; this.methods = methods; this.implemented = implemented; this.modifier = modifier; this.name = name; this.pkg = pkg; this.names = names; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code declaredTypes} attribute */ @Override public List declaredTypes() { return declaredTypes; } /** * @return The value of the {@code fields} attribute */ @Override public List fields() { return fields; } /** * @return The value of the {@code methods} attribute */ @Override public List methods() { return methods; } /** * @return The value of the {@code implemented} attribute */ @Override public List implemented() { return implemented; } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code pkg} attribute */ @Override public Models.Pkg pkg() { return pkg; } /** * @return The value of the {@code names} attribute */ @Override public List names() { return names; } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.EnumType( newValue, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.EnumType( newValue, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.EnumType#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.EnumType withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.EnumType( this.annotations, newValue, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object by setting an optional value for the {@link Model.EnumType#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.EnumType withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.EnumType( this.annotations, value, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#declaredTypes() declaredTypes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withDeclaredTypes(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.EnumType( this.annotations, this.declaringType, newValue, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#declaredTypes() declaredTypes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of declaredTypes elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withDeclaredTypes(Iterable elements) { if (this.declaredTypes == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.EnumType( this.annotations, this.declaringType, newValue, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#fields() fields}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withFields(Model.Field... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.methods, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#fields() fields}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of fields elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withFields(Iterable elements) { if (this.fields == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.methods, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#methods() methods}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withMethods(Model.Method... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, this.fields, newValue, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#methods() methods}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of methods elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withMethods(Iterable elements) { if (this.methods == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, this.fields, newValue, this.implemented, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#implemented() implemented}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withImplemented(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, newValue, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#implemented() implemented}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of implemented elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withImplemented(Iterable elements) { if (this.implemented == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, newValue, this.modifier, this.name, this.pkg, this.names); } /** * Copy the current immutable object by setting a value for the {@link Model.EnumType#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.EnumType withModifier(int value) { if (this.modifier == value) return this; return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, value, this.name, this.pkg, this.names); } /** * Copy the current immutable object by setting a value for the {@link Model.EnumType#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.EnumType withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, newValue, this.pkg, this.names); } /** * Copy the current immutable object by setting a value for the {@link Model.EnumType#pkg() pkg} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for pkg * @return A modified copy of the {@code this} object */ public final Models.EnumType withPkg(Model.Pkg value) { if (this.pkg == value) return this; Models.Pkg newValue = Models.Pkg.copyOf(value); return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, newValue, this.names); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#names() names}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withNames(String... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link Model.EnumType#names() names}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of names elements to set * @return A modified copy of {@code this} object */ public final Models.EnumType withNames(Iterable elements) { if (this.names == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.EnumType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg, newValue); } /** * This instance is equal to all instances of {@code EnumType} 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 Models.EnumType && equalTo(0, (Models.EnumType) another); } private boolean equalTo(int synthetic, Models.EnumType another) { return annotations.equals(another.annotations) && Objects.equals(declaringType, another.declaringType) && declaredTypes.equals(another.declaredTypes) && fields.equals(another.fields) && methods.equals(another.methods) && implemented.equals(another.implemented) && modifier == another.modifier && name.equals(another.name) && pkg.equals(another.pkg) && names.equals(another.names); } /** * Computes a hash code from attributes: {@code annotations}, {@code declaringType}, {@code declaredTypes}, {@code fields}, {@code methods}, {@code implemented}, {@code modifier}, {@code name}, {@code pkg}, {@code names}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + declaredTypes.hashCode(); h += (h << 5) + fields.hashCode(); h += (h << 5) + methods.hashCode(); h += (h << 5) + implemented.hashCode(); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); h += (h << 5) + pkg.hashCode(); h += (h << 5) + names.hashCode(); return h; } /** * Prints the immutable value {@code EnumType} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("EnumType{"); builder.append("annotations=").append(annotations); if (declaringType != null) { builder.append(", "); builder.append("declaringType=").append(declaringType); } builder.append(", "); builder.append("declaredTypes=").append(declaredTypes); builder.append(", "); builder.append("fields=").append(fields); builder.append(", "); builder.append("methods=").append(methods); builder.append(", "); builder.append("implemented=").append(implemented); builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); builder.append(", "); builder.append("pkg=").append(pkg); builder.append(", "); builder.append("names=").append(names); return builder.append("}").toString(); } /** * Construct a new immutable {@code EnumType} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @param pkg The value for the {@code pkg} attribute * @return An immutable EnumType instance */ public static Models.EnumType of(int modifier, String name, Model.Pkg pkg) { return new Models.EnumType(modifier, name, pkg); } /** * Creates an immutable copy of a {@link Model.EnumType} 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 EnumType instance */ public static Models.EnumType copyOf(Model.EnumType instance) { if (instance instanceof Models.EnumType) { return (Models.EnumType) instance; } return Models.EnumType.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.EnumType EnumType}. *

     * Models.EnumType.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.EnumType#annotations() annotations} elements
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.EnumType#declaringType() declaringType}
     *    .addDeclaredTypes|addAllDeclaredTypes(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.EnumType#declaredTypes() declaredTypes} elements
     *    .addFields|addAllFields(cn.zenliu.units.codegen.model.Model.Field) // {@link Model.EnumType#fields() fields} elements
     *    .addMethods|addAllMethods(cn.zenliu.units.codegen.model.Model.Method) // {@link Model.EnumType#methods() methods} elements
     *    .addImplemented|addAllImplemented(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.EnumType#implemented() implemented} elements
     *    .modifier(int) // required {@link Model.EnumType#modifier() modifier}
     *    .name(String) // required {@link Model.EnumType#name() name}
     *    .pkg(cn.zenliu.units.codegen.model.Model.Pkg) // required {@link Model.EnumType#pkg() pkg}
     *    .addNames|addAllNames(String) // {@link Model.EnumType#names() names} elements
     *    .build();
     * 
* @return A new EnumType builder */ public static Models.EnumType.Builder builder() { return new Models.EnumType.Builder(); } /** * Builds instances of type {@link Models.EnumType EnumType}. * 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 = "Model.EnumType", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private static final long INIT_BIT_PKG = 0x4L; private long initBits = 0x7L; private List annotations = new ArrayList(); private @Nullable Model.Type declaringType; private List declaredTypes = new ArrayList(); private List fields = new ArrayList(); private List methods = new ArrayList(); private List implemented = new ArrayList(); private int modifier; private @Nullable String name; private @Nullable Model.Pkg pkg; private List names = new ArrayList(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.EnumType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.EnumType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Implements} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Implements instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaredTypes} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaredTypes instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Type} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Type instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Package} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Package instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.MethodHolder} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.MethodHolder instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.FieldHolder} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.FieldHolder instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.EnumType) { Model.EnumType instance = (Model.EnumType) object; addAllNames(instance.names()); if ((bits & 0x1L) == 0) { addAllMethods(instance.methods()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } if ((bits & 0x20L) == 0) { addAllImplemented(instance.implemented()); bits |= 0x20L; } if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x80L) == 0) { addAllFields(instance.fields()); bits |= 0x80L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x100L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x100L; } } if (object instanceof Model.With.Implements) { Model.With.Implements instance = (Model.With.Implements) object; if ((bits & 0x20L) == 0) { addAllImplemented(instance.implemented()); bits |= 0x20L; } } if (object instanceof Model.With.DeclaredTypes) { Model.With.DeclaredTypes instance = (Model.With.DeclaredTypes) object; if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } } if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x100L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x100L; } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } } if (object instanceof Model.Type) { Model.Type instance = (Model.Type) object; if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x100L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x100L; } if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } } if (object instanceof Model.With.Package) { Model.With.Package instance = (Model.With.Package) object; if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } } if (object instanceof Model.With.MethodHolder) { Model.With.MethodHolder instance = (Model.With.MethodHolder) object; if ((bits & 0x1L) == 0) { addAllMethods(instance.methods()); bits |= 0x1L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } } if (object instanceof Model.With.FieldHolder) { Model.With.FieldHolder instance = (Model.With.FieldHolder) object; if ((bits & 0x80L) == 0) { addAllFields(instance.fields()); bits |= 0x80L; } } } /** * Adds one element to {@link Model.EnumType#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.EnumType#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.EnumType#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.EnumType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.EnumType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the optional value {@link Model.EnumType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.EnumType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Adds one element to {@link Model.EnumType#declaredTypes() declaredTypes} list. * @param element A declaredTypes element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type element) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); return this; } /** * Adds elements to {@link Model.EnumType#declaredTypes() declaredTypes} list. * @param elements An array of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type... elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Sets or replaces all elements for {@link Model.EnumType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaredTypes(Iterable elements) { this.declaredTypes.clear(); return addAllDeclaredTypes(elements); } /** * Adds elements to {@link Model.EnumType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllDeclaredTypes(Iterable elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Adds one element to {@link Model.EnumType#fields() fields} list. * @param element A fields element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFields(Model.Field element) { element = Models.Field.copyOf(element); this.fields.add(Objects.requireNonNull(element, "fields element")); return this; } /** * Constructs and adds an element for the {@link Model.EnumType#fields() fields} list. * @param modifier The value for {@code fields.modifier} * @param name The value for {@code fields.name} * @param type The value for {@code fields.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addFields(int modifier, String name, Model.Type type) { return addFields(Models.Field.of(modifier, name, type)); } /** * Adds elements to {@link Model.EnumType#fields() fields} list. * @param elements An array of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFields(Model.Field... elements) { for (Model.Field element : elements) { element = Models.Field.copyOf(element); this.fields.add(Objects.requireNonNull(element, "fields element")); } return this; } /** * Sets or replaces all elements for {@link Model.EnumType#fields() fields} list. * @param elements An iterable of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder fields(Iterable elements) { this.fields.clear(); return addAllFields(elements); } /** * Adds elements to {@link Model.EnumType#fields() fields} list. * @param elements An iterable of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllFields(Iterable elements) { for (Model.Field element : elements) { element = Models.Field.copyOf(element); this.fields.add(Objects.requireNonNull(element, "fields element")); } return this; } /** * Adds one element to {@link Model.EnumType#methods() methods} list. * @param element A methods element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMethods(Model.Method element) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); return this; } /** * Constructs and adds an element for the {@link Model.EnumType#methods() methods} list. * @param modifier The value for {@code methods.modifier} * @param name The value for {@code methods.name} * @return {@code this} builder for use in a chained invocation */ public final Builder addMethods(int modifier, String name) { return addMethods(Models.Method.of(modifier, name)); } /** * Adds elements to {@link Model.EnumType#methods() methods} list. * @param elements An array of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMethods(Model.Method... elements) { for (Model.Method element : elements) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); } return this; } /** * Sets or replaces all elements for {@link Model.EnumType#methods() methods} list. * @param elements An iterable of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder methods(Iterable elements) { this.methods.clear(); return addAllMethods(elements); } /** * Adds elements to {@link Model.EnumType#methods() methods} list. * @param elements An iterable of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllMethods(Iterable elements) { for (Model.Method element : elements) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); } return this; } /** * Adds one element to {@link Model.EnumType#implemented() implemented} list. * @param element A implemented element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addImplemented(Model.Type element) { this.implemented.add(Objects.requireNonNull(element, "implemented element")); return this; } /** * Adds elements to {@link Model.EnumType#implemented() implemented} list. * @param elements An array of implemented elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addImplemented(Model.Type... elements) { for (Model.Type element : elements) { this.implemented.add(Objects.requireNonNull(element, "implemented element")); } return this; } /** * Sets or replaces all elements for {@link Model.EnumType#implemented() implemented} list. * @param elements An iterable of implemented elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder implemented(Iterable elements) { this.implemented.clear(); return addAllImplemented(elements); } /** * Adds elements to {@link Model.EnumType#implemented() implemented} list. * @param elements An iterable of implemented elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllImplemented(Iterable elements) { for (Model.Type element : elements) { this.implemented.add(Objects.requireNonNull(element, "implemented element")); } return this; } /** * Initializes the value for the {@link Model.EnumType#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.EnumType#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Constructs and initializes the value for the {@link Model.EnumType#pkg() pkg} attribute. * @param name The value for {@code pkg.name} * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(String name) { return pkg(Models.Pkg.of(name)); } /** * Initializes the value for the {@link Model.EnumType#pkg() pkg} attribute. * @param pkg The value for pkg * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(Model.Pkg pkg) { this.pkg = Models.Pkg.copyOf(pkg); initBits &= ~INIT_BIT_PKG; return this; } /** * Adds one element to {@link Model.EnumType#names() names} list. * @param element A names element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addNames(String element) { this.names.add(Objects.requireNonNull(element, "names element")); return this; } /** * Adds elements to {@link Model.EnumType#names() names} list. * @param elements An array of names elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addNames(String... elements) { for (String element : elements) { this.names.add(Objects.requireNonNull(element, "names element")); } return this; } /** * Sets or replaces all elements for {@link Model.EnumType#names() names} list. * @param elements An iterable of names elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder names(Iterable elements) { this.names.clear(); return addAllNames(elements); } /** * Adds elements to {@link Model.EnumType#names() names} list. * @param elements An iterable of names elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllNames(Iterable elements) { for (String element : elements) { this.names.add(Objects.requireNonNull(element, "names element")); } return this; } /** * Builds a new {@link Models.EnumType EnumType}. * @return An immutable instance of EnumType * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.EnumType build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.EnumType( createUnmodifiableList(true, annotations), declaringType, createUnmodifiableList(true, declaredTypes), createUnmodifiableList(true, fields), createUnmodifiableList(true, methods), createUnmodifiableList(true, implemented), modifier, name, Models.Pkg.copyOf(pkg), createUnmodifiableList(true, names)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_PKG) != 0) attributes.add("pkg"); return "Cannot build EnumType, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.RecordType}. *

* Use the builder to create immutable instances: * {@code Models.RecordType.builder()}. * Use the static factory method to create immutable instances: * {@code Models.RecordType.of()}. */ @Generated(from = "Model.RecordType", generator = "Immutables") @Immutable @CheckReturnValue public static final class RecordType implements Model.RecordType { private final List annotations; private final @Nullable Model.Type declaringType; private final List declaredTypes; private final List fields; private final List methods; private final List implemented; private final int modifier; private final String name; private final Models.Pkg pkg; private RecordType(int modifier, String name, Model.Pkg pkg) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.pkg = Models.Pkg.copyOf(pkg); this.annotations = Collections.emptyList(); this.declaringType = null; this.declaredTypes = Collections.emptyList(); this.fields = Collections.emptyList(); this.methods = Collections.emptyList(); this.implemented = Collections.emptyList(); } private RecordType( List annotations, @Nullable Model.Type declaringType, List declaredTypes, List fields, List methods, List implemented, int modifier, String name, Models.Pkg pkg) { this.annotations = annotations; this.declaringType = declaringType; this.declaredTypes = declaredTypes; this.fields = fields; this.methods = methods; this.implemented = implemented; this.modifier = modifier; this.name = name; this.pkg = pkg; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code declaredTypes} attribute */ @Override public List declaredTypes() { return declaredTypes; } /** * @return The value of the {@code fields} attribute */ @Override public List fields() { return fields; } /** * @return The value of the {@code methods} attribute */ @Override public List methods() { return methods; } /** * @return The value of the {@code implemented} attribute */ @Override public List implemented() { return implemented; } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code pkg} attribute */ @Override public Models.Pkg pkg() { return pkg; } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RecordType( newValue, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RecordType( newValue, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.RecordType#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.RecordType withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.RecordType( this.annotations, newValue, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting an optional value for the {@link Model.RecordType#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.RecordType withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.RecordType( this.annotations, value, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#declaredTypes() declaredTypes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withDeclaredTypes(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RecordType( this.annotations, this.declaringType, newValue, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#declaredTypes() declaredTypes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of declaredTypes elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withDeclaredTypes(Iterable elements) { if (this.declaredTypes == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RecordType( this.annotations, this.declaringType, newValue, this.fields, this.methods, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#fields() fields}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withFields(Model.Field... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RecordType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.methods, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#fields() fields}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of fields elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withFields(Iterable elements) { if (this.fields == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RecordType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.methods, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#methods() methods}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withMethods(Model.Method... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RecordType( this.annotations, this.declaringType, this.declaredTypes, this.fields, newValue, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#methods() methods}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of methods elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withMethods(Iterable elements) { if (this.methods == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RecordType( this.annotations, this.declaringType, this.declaredTypes, this.fields, newValue, this.implemented, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#implemented() implemented}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withImplemented(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.RecordType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, newValue, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.RecordType#implemented() implemented}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of implemented elements to set * @return A modified copy of {@code this} object */ public final Models.RecordType withImplemented(Iterable elements) { if (this.implemented == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.RecordType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, newValue, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.RecordType#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.RecordType withModifier(int value) { if (this.modifier == value) return this; return new Models.RecordType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, value, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.RecordType#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.RecordType withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.RecordType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, newValue, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.RecordType#pkg() pkg} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for pkg * @return A modified copy of the {@code this} object */ public final Models.RecordType withPkg(Model.Pkg value) { if (this.pkg == value) return this; Models.Pkg newValue = Models.Pkg.copyOf(value); return new Models.RecordType( this.annotations, this.declaringType, this.declaredTypes, this.fields, this.methods, this.implemented, this.modifier, this.name, newValue); } /** * This instance is equal to all instances of {@code RecordType} 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 Models.RecordType && equalTo(0, (Models.RecordType) another); } private boolean equalTo(int synthetic, Models.RecordType another) { return annotations.equals(another.annotations) && Objects.equals(declaringType, another.declaringType) && declaredTypes.equals(another.declaredTypes) && fields.equals(another.fields) && methods.equals(another.methods) && implemented.equals(another.implemented) && modifier == another.modifier && name.equals(another.name) && pkg.equals(another.pkg); } /** * Computes a hash code from attributes: {@code annotations}, {@code declaringType}, {@code declaredTypes}, {@code fields}, {@code methods}, {@code implemented}, {@code modifier}, {@code name}, {@code pkg}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + declaredTypes.hashCode(); h += (h << 5) + fields.hashCode(); h += (h << 5) + methods.hashCode(); h += (h << 5) + implemented.hashCode(); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); h += (h << 5) + pkg.hashCode(); return h; } /** * Prints the immutable value {@code RecordType} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("RecordType{"); builder.append("annotations=").append(annotations); if (declaringType != null) { builder.append(", "); builder.append("declaringType=").append(declaringType); } builder.append(", "); builder.append("declaredTypes=").append(declaredTypes); builder.append(", "); builder.append("fields=").append(fields); builder.append(", "); builder.append("methods=").append(methods); builder.append(", "); builder.append("implemented=").append(implemented); builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); builder.append(", "); builder.append("pkg=").append(pkg); return builder.append("}").toString(); } /** * Construct a new immutable {@code RecordType} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @param pkg The value for the {@code pkg} attribute * @return An immutable RecordType instance */ public static Models.RecordType of(int modifier, String name, Model.Pkg pkg) { return new Models.RecordType(modifier, name, pkg); } /** * Creates an immutable copy of a {@link Model.RecordType} 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 RecordType instance */ public static Models.RecordType copyOf(Model.RecordType instance) { if (instance instanceof Models.RecordType) { return (Models.RecordType) instance; } return Models.RecordType.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.RecordType RecordType}. *

     * Models.RecordType.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.RecordType#annotations() annotations} elements
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.RecordType#declaringType() declaringType}
     *    .addDeclaredTypes|addAllDeclaredTypes(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.RecordType#declaredTypes() declaredTypes} elements
     *    .addFields|addAllFields(cn.zenliu.units.codegen.model.Model.Field) // {@link Model.RecordType#fields() fields} elements
     *    .addMethods|addAllMethods(cn.zenliu.units.codegen.model.Model.Method) // {@link Model.RecordType#methods() methods} elements
     *    .addImplemented|addAllImplemented(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.RecordType#implemented() implemented} elements
     *    .modifier(int) // required {@link Model.RecordType#modifier() modifier}
     *    .name(String) // required {@link Model.RecordType#name() name}
     *    .pkg(cn.zenliu.units.codegen.model.Model.Pkg) // required {@link Model.RecordType#pkg() pkg}
     *    .build();
     * 
* @return A new RecordType builder */ public static Models.RecordType.Builder builder() { return new Models.RecordType.Builder(); } /** * Builds instances of type {@link Models.RecordType RecordType}. * 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 = "Model.RecordType", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private static final long INIT_BIT_PKG = 0x4L; private long initBits = 0x7L; private List annotations = new ArrayList(); private @Nullable Model.Type declaringType; private List declaredTypes = new ArrayList(); private List fields = new ArrayList(); private List methods = new ArrayList(); private List implemented = new ArrayList(); private int modifier; private @Nullable String name; private @Nullable Model.Pkg pkg; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Implements} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Implements instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaredTypes} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaredTypes instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Type} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Type instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.RecordType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.RecordType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Package} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Package instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.MethodHolder} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.MethodHolder instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.FieldHolder} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.FieldHolder instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.Implements) { Model.With.Implements instance = (Model.With.Implements) object; if ((bits & 0x20L) == 0) { addAllImplemented(instance.implemented()); bits |= 0x20L; } } if (object instanceof Model.With.DeclaredTypes) { Model.With.DeclaredTypes instance = (Model.With.DeclaredTypes) object; if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } } if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x100L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x100L; } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } } if (object instanceof Model.Type) { Model.Type instance = (Model.Type) object; if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x100L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x100L; } if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } } if (object instanceof Model.RecordType) { Model.RecordType instance = (Model.RecordType) object; if ((bits & 0x1L) == 0) { addAllMethods(instance.methods()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } if ((bits & 0x20L) == 0) { addAllImplemented(instance.implemented()); bits |= 0x20L; } if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x80L) == 0) { addAllFields(instance.fields()); bits |= 0x80L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x100L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x100L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } } if (object instanceof Model.With.Package) { Model.With.Package instance = (Model.With.Package) object; if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } } if (object instanceof Model.With.MethodHolder) { Model.With.MethodHolder instance = (Model.With.MethodHolder) object; if ((bits & 0x1L) == 0) { addAllMethods(instance.methods()); bits |= 0x1L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } } if (object instanceof Model.With.FieldHolder) { Model.With.FieldHolder instance = (Model.With.FieldHolder) object; if ((bits & 0x80L) == 0) { addAllFields(instance.fields()); bits |= 0x80L; } } } /** * Adds one element to {@link Model.RecordType#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.RecordType#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.RecordType#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.RecordType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.RecordType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the optional value {@link Model.RecordType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.RecordType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Adds one element to {@link Model.RecordType#declaredTypes() declaredTypes} list. * @param element A declaredTypes element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type element) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); return this; } /** * Adds elements to {@link Model.RecordType#declaredTypes() declaredTypes} list. * @param elements An array of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type... elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Sets or replaces all elements for {@link Model.RecordType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaredTypes(Iterable elements) { this.declaredTypes.clear(); return addAllDeclaredTypes(elements); } /** * Adds elements to {@link Model.RecordType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllDeclaredTypes(Iterable elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Adds one element to {@link Model.RecordType#fields() fields} list. * @param element A fields element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFields(Model.Field element) { element = Models.Field.copyOf(element); this.fields.add(Objects.requireNonNull(element, "fields element")); return this; } /** * Constructs and adds an element for the {@link Model.RecordType#fields() fields} list. * @param modifier The value for {@code fields.modifier} * @param name The value for {@code fields.name} * @param type The value for {@code fields.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addFields(int modifier, String name, Model.Type type) { return addFields(Models.Field.of(modifier, name, type)); } /** * Adds elements to {@link Model.RecordType#fields() fields} list. * @param elements An array of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFields(Model.Field... elements) { for (Model.Field element : elements) { element = Models.Field.copyOf(element); this.fields.add(Objects.requireNonNull(element, "fields element")); } return this; } /** * Sets or replaces all elements for {@link Model.RecordType#fields() fields} list. * @param elements An iterable of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder fields(Iterable elements) { this.fields.clear(); return addAllFields(elements); } /** * Adds elements to {@link Model.RecordType#fields() fields} list. * @param elements An iterable of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllFields(Iterable elements) { for (Model.Field element : elements) { element = Models.Field.copyOf(element); this.fields.add(Objects.requireNonNull(element, "fields element")); } return this; } /** * Adds one element to {@link Model.RecordType#methods() methods} list. * @param element A methods element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMethods(Model.Method element) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); return this; } /** * Constructs and adds an element for the {@link Model.RecordType#methods() methods} list. * @param modifier The value for {@code methods.modifier} * @param name The value for {@code methods.name} * @return {@code this} builder for use in a chained invocation */ public final Builder addMethods(int modifier, String name) { return addMethods(Models.Method.of(modifier, name)); } /** * Adds elements to {@link Model.RecordType#methods() methods} list. * @param elements An array of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMethods(Model.Method... elements) { for (Model.Method element : elements) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); } return this; } /** * Sets or replaces all elements for {@link Model.RecordType#methods() methods} list. * @param elements An iterable of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder methods(Iterable elements) { this.methods.clear(); return addAllMethods(elements); } /** * Adds elements to {@link Model.RecordType#methods() methods} list. * @param elements An iterable of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllMethods(Iterable elements) { for (Model.Method element : elements) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); } return this; } /** * Adds one element to {@link Model.RecordType#implemented() implemented} list. * @param element A implemented element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addImplemented(Model.Type element) { this.implemented.add(Objects.requireNonNull(element, "implemented element")); return this; } /** * Adds elements to {@link Model.RecordType#implemented() implemented} list. * @param elements An array of implemented elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addImplemented(Model.Type... elements) { for (Model.Type element : elements) { this.implemented.add(Objects.requireNonNull(element, "implemented element")); } return this; } /** * Sets or replaces all elements for {@link Model.RecordType#implemented() implemented} list. * @param elements An iterable of implemented elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder implemented(Iterable elements) { this.implemented.clear(); return addAllImplemented(elements); } /** * Adds elements to {@link Model.RecordType#implemented() implemented} list. * @param elements An iterable of implemented elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllImplemented(Iterable elements) { for (Model.Type element : elements) { this.implemented.add(Objects.requireNonNull(element, "implemented element")); } return this; } /** * Initializes the value for the {@link Model.RecordType#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.RecordType#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Constructs and initializes the value for the {@link Model.RecordType#pkg() pkg} attribute. * @param name The value for {@code pkg.name} * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(String name) { return pkg(Models.Pkg.of(name)); } /** * Initializes the value for the {@link Model.RecordType#pkg() pkg} attribute. * @param pkg The value for pkg * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(Model.Pkg pkg) { this.pkg = Models.Pkg.copyOf(pkg); initBits &= ~INIT_BIT_PKG; return this; } /** * Builds a new {@link Models.RecordType RecordType}. * @return An immutable instance of RecordType * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.RecordType build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.RecordType( createUnmodifiableList(true, annotations), declaringType, createUnmodifiableList(true, declaredTypes), createUnmodifiableList(true, fields), createUnmodifiableList(true, methods), createUnmodifiableList(true, implemented), modifier, name, Models.Pkg.copyOf(pkg)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_PKG) != 0) attributes.add("pkg"); return "Cannot build RecordType, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.ArrayType}. *

* Use the builder to create immutable instances: * {@code Models.ArrayType.builder()}. * Use the static factory method to create immutable instances: * {@code Models.ArrayType.of()}. */ @Generated(from = "Model.ArrayType", generator = "Immutables") @Immutable @CheckReturnValue public static final class ArrayType implements Model.ArrayType { private final List annotations; private final @Nullable Model.Type declaringType; private final List declaredTypes; private final int modifier; private final String name; private final Models.Pkg pkg; private final @Nullable Model.Type componentType; private final int dimension; private ArrayType(int modifier, String name, Model.Pkg pkg, int dimension) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.pkg = Models.Pkg.copyOf(pkg); this.dimension = dimension; this.annotations = Collections.emptyList(); this.declaringType = null; this.declaredTypes = Collections.emptyList(); this.componentType = null; } private ArrayType( List annotations, @Nullable Model.Type declaringType, List declaredTypes, int modifier, String name, Models.Pkg pkg, @Nullable Model.Type componentType, int dimension) { this.annotations = annotations; this.declaringType = declaringType; this.declaredTypes = declaredTypes; this.modifier = modifier; this.name = name; this.pkg = pkg; this.componentType = componentType; this.dimension = dimension; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code declaredTypes} attribute */ @Override public List declaredTypes() { return declaredTypes; } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code pkg} attribute */ @Override public Models.Pkg pkg() { return pkg; } /** * @return The value of the {@code componentType} attribute */ @Override public Optional componentType() { return Optional.ofNullable(componentType); } /** * @return The value of the {@code dimension} attribute */ @Override public int dimension() { return dimension; } /** * Copy the current immutable object with elements that replace the content of {@link Model.ArrayType#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.ArrayType withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.ArrayType( newValue, this.declaringType, this.declaredTypes, this.modifier, this.name, this.pkg, this.componentType, this.dimension); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ArrayType#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.ArrayType withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.ArrayType( newValue, this.declaringType, this.declaredTypes, this.modifier, this.name, this.pkg, this.componentType, this.dimension); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.ArrayType#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.ArrayType withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.ArrayType( this.annotations, newValue, this.declaredTypes, this.modifier, this.name, this.pkg, this.componentType, this.dimension); } /** * Copy the current immutable object by setting an optional value for the {@link Model.ArrayType#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.ArrayType withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.ArrayType( this.annotations, value, this.declaredTypes, this.modifier, this.name, this.pkg, this.componentType, this.dimension); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ArrayType#declaredTypes() declaredTypes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.ArrayType withDeclaredTypes(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.ArrayType( this.annotations, this.declaringType, newValue, this.modifier, this.name, this.pkg, this.componentType, this.dimension); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ArrayType#declaredTypes() declaredTypes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of declaredTypes elements to set * @return A modified copy of {@code this} object */ public final Models.ArrayType withDeclaredTypes(Iterable elements) { if (this.declaredTypes == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.ArrayType( this.annotations, this.declaringType, newValue, this.modifier, this.name, this.pkg, this.componentType, this.dimension); } /** * Copy the current immutable object by setting a value for the {@link Model.ArrayType#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.ArrayType withModifier(int value) { if (this.modifier == value) return this; return new Models.ArrayType( this.annotations, this.declaringType, this.declaredTypes, value, this.name, this.pkg, this.componentType, this.dimension); } /** * Copy the current immutable object by setting a value for the {@link Model.ArrayType#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.ArrayType withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.ArrayType( this.annotations, this.declaringType, this.declaredTypes, this.modifier, newValue, this.pkg, this.componentType, this.dimension); } /** * Copy the current immutable object by setting a value for the {@link Model.ArrayType#pkg() pkg} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for pkg * @return A modified copy of the {@code this} object */ public final Models.ArrayType withPkg(Model.Pkg value) { if (this.pkg == value) return this; Models.Pkg newValue = Models.Pkg.copyOf(value); return new Models.ArrayType( this.annotations, this.declaringType, this.declaredTypes, this.modifier, this.name, newValue, this.componentType, this.dimension); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.ArrayType#componentType() componentType} attribute. * @param value The value for componentType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.ArrayType withComponentType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.componentType == newValue) return this; return new Models.ArrayType( this.annotations, this.declaringType, this.declaredTypes, this.modifier, this.name, this.pkg, newValue, this.dimension); } /** * Copy the current immutable object by setting an optional value for the {@link Model.ArrayType#componentType() componentType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for componentType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.ArrayType withComponentType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.componentType == value) return this; return new Models.ArrayType( this.annotations, this.declaringType, this.declaredTypes, this.modifier, this.name, this.pkg, value, this.dimension); } /** * Copy the current immutable object by setting a value for the {@link Model.ArrayType#dimension() dimension} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for dimension * @return A modified copy of the {@code this} object */ public final Models.ArrayType withDimension(int value) { if (this.dimension == value) return this; return new Models.ArrayType( this.annotations, this.declaringType, this.declaredTypes, this.modifier, this.name, this.pkg, this.componentType, value); } /** * This instance is equal to all instances of {@code ArrayType} 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 Models.ArrayType && equalTo(0, (Models.ArrayType) another); } private boolean equalTo(int synthetic, Models.ArrayType another) { return annotations.equals(another.annotations) && Objects.equals(declaringType, another.declaringType) && declaredTypes.equals(another.declaredTypes) && modifier == another.modifier && name.equals(another.name) && pkg.equals(another.pkg) && Objects.equals(componentType, another.componentType) && dimension == another.dimension; } /** * Computes a hash code from attributes: {@code annotations}, {@code declaringType}, {@code declaredTypes}, {@code modifier}, {@code name}, {@code pkg}, {@code componentType}, {@code dimension}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + declaredTypes.hashCode(); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); h += (h << 5) + pkg.hashCode(); h += (h << 5) + Objects.hashCode(componentType); h += (h << 5) + dimension; return h; } /** * Prints the immutable value {@code ArrayType} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ArrayType{"); builder.append("annotations=").append(annotations); if (declaringType != null) { builder.append(", "); builder.append("declaringType=").append(declaringType); } builder.append(", "); builder.append("declaredTypes=").append(declaredTypes); builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); builder.append(", "); builder.append("pkg=").append(pkg); if (componentType != null) { builder.append(", "); builder.append("componentType=").append(componentType); } builder.append(", "); builder.append("dimension=").append(dimension); return builder.append("}").toString(); } /** * Construct a new immutable {@code ArrayType} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @param pkg The value for the {@code pkg} attribute * @param dimension The value for the {@code dimension} attribute * @return An immutable ArrayType instance */ public static Models.ArrayType of(int modifier, String name, Model.Pkg pkg, int dimension) { return new Models.ArrayType(modifier, name, pkg, dimension); } /** * Creates an immutable copy of a {@link Model.ArrayType} 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 ArrayType instance */ public static Models.ArrayType copyOf(Model.ArrayType instance) { if (instance instanceof Models.ArrayType) { return (Models.ArrayType) instance; } return Models.ArrayType.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.ArrayType ArrayType}. *

     * Models.ArrayType.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.ArrayType#annotations() annotations} elements
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.ArrayType#declaringType() declaringType}
     *    .addDeclaredTypes|addAllDeclaredTypes(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.ArrayType#declaredTypes() declaredTypes} elements
     *    .modifier(int) // required {@link Model.ArrayType#modifier() modifier}
     *    .name(String) // required {@link Model.ArrayType#name() name}
     *    .pkg(cn.zenliu.units.codegen.model.Model.Pkg) // required {@link Model.ArrayType#pkg() pkg}
     *    .componentType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.ArrayType#componentType() componentType}
     *    .dimension(int) // required {@link Model.ArrayType#dimension() dimension}
     *    .build();
     * 
* @return A new ArrayType builder */ public static Models.ArrayType.Builder builder() { return new Models.ArrayType.Builder(); } /** * Builds instances of type {@link Models.ArrayType ArrayType}. * 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 = "Model.ArrayType", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private static final long INIT_BIT_PKG = 0x4L; private static final long INIT_BIT_DIMENSION = 0x8L; private long initBits = 0xfL; private List annotations = new ArrayList(); private @Nullable Model.Type declaringType; private List declaredTypes = new ArrayList(); private int modifier; private @Nullable String name; private @Nullable Model.Pkg pkg; private @Nullable Model.Type componentType; private int dimension; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.ArrayType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.ArrayType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaredTypes} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaredTypes instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Type} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Type instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Package} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Package instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.ArrayType) { Model.ArrayType instance = (Model.ArrayType) object; Optional componentTypeOptional = instance.componentType(); if (componentTypeOptional.isPresent()) { componentType(componentTypeOptional); } if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } if ((bits & 0x10L) == 0) { name(instance.name()); bits |= 0x10L; } if ((bits & 0x4L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x4L; } if ((bits & 0x8L) == 0) { pkg(instance.pkg()); bits |= 0x8L; } if ((bits & 0x20L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x20L; } dimension(instance.dimension()); } if (object instanceof Model.With.DeclaredTypes) { Model.With.DeclaredTypes instance = (Model.With.DeclaredTypes) object; if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } } if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x20L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x20L; } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x10L) == 0) { name(instance.name()); bits |= 0x10L; } } if (object instanceof Model.Type) { Model.Type instance = (Model.Type) object; if ((bits & 0x10L) == 0) { name(instance.name()); bits |= 0x10L; } if ((bits & 0x4L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x4L; } if ((bits & 0x8L) == 0) { pkg(instance.pkg()); bits |= 0x8L; } if ((bits & 0x20L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x20L; } if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x4L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x4L; } } if (object instanceof Model.With.Package) { Model.With.Package instance = (Model.With.Package) object; if ((bits & 0x8L) == 0) { pkg(instance.pkg()); bits |= 0x8L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } } } /** * Adds one element to {@link Model.ArrayType#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.ArrayType#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.ArrayType#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.ArrayType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.ArrayType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the optional value {@link Model.ArrayType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.ArrayType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Adds one element to {@link Model.ArrayType#declaredTypes() declaredTypes} list. * @param element A declaredTypes element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type element) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); return this; } /** * Adds elements to {@link Model.ArrayType#declaredTypes() declaredTypes} list. * @param elements An array of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type... elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Sets or replaces all elements for {@link Model.ArrayType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaredTypes(Iterable elements) { this.declaredTypes.clear(); return addAllDeclaredTypes(elements); } /** * Adds elements to {@link Model.ArrayType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllDeclaredTypes(Iterable elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Initializes the value for the {@link Model.ArrayType#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.ArrayType#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Constructs and initializes the value for the {@link Model.ArrayType#pkg() pkg} attribute. * @param name The value for {@code pkg.name} * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(String name) { return pkg(Models.Pkg.of(name)); } /** * Initializes the value for the {@link Model.ArrayType#pkg() pkg} attribute. * @param pkg The value for pkg * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(Model.Pkg pkg) { this.pkg = Models.Pkg.copyOf(pkg); initBits &= ~INIT_BIT_PKG; return this; } /** * Initializes the optional value {@link Model.ArrayType#componentType() componentType} to componentType. * @param componentType The value for componentType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder componentType(@Nullable Model.Type componentType) { this.componentType = componentType; return this; } /** * Initializes the optional value {@link Model.ArrayType#componentType() componentType} to componentType. * @param componentType The value for componentType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder componentType(Optional componentType) { this.componentType = componentType.orElse(null); return this; } /** * Initializes the value for the {@link Model.ArrayType#dimension() dimension} attribute. * @param dimension The value for dimension * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder dimension(int dimension) { this.dimension = dimension; initBits &= ~INIT_BIT_DIMENSION; return this; } /** * Builds a new {@link Models.ArrayType ArrayType}. * @return An immutable instance of ArrayType * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.ArrayType build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.ArrayType( createUnmodifiableList(true, annotations), declaringType, createUnmodifiableList(true, declaredTypes), modifier, name, Models.Pkg.copyOf(pkg), componentType, dimension); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_PKG) != 0) attributes.add("pkg"); if ((initBits & INIT_BIT_DIMENSION) != 0) attributes.add("dimension"); return "Cannot build ArrayType, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.AnnotationType}. *

* Use the builder to create immutable instances: * {@code Models.AnnotationType.builder()}. * Use the static factory method to create immutable instances: * {@code Models.AnnotationType.of()}. */ @Generated(from = "Model.AnnotationType", generator = "Immutables") @Immutable @CheckReturnValue public static final class AnnotationType implements Model.AnnotationType { private final List annotations; private final @Nullable Model.Type declaringType; private final List declaredTypes; private final List methods; private final int modifier; private final String name; private final Models.Pkg pkg; private AnnotationType(int modifier, String name, Model.Pkg pkg) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.pkg = Models.Pkg.copyOf(pkg); this.annotations = Collections.emptyList(); this.declaringType = null; this.declaredTypes = Collections.emptyList(); this.methods = Collections.emptyList(); } private AnnotationType( List annotations, @Nullable Model.Type declaringType, List declaredTypes, List methods, int modifier, String name, Models.Pkg pkg) { this.annotations = annotations; this.declaringType = declaringType; this.declaredTypes = declaredTypes; this.methods = methods; this.modifier = modifier; this.name = name; this.pkg = pkg; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code declaredTypes} attribute */ @Override public List declaredTypes() { return declaredTypes; } /** * @return The value of the {@code methods} attribute */ @Override public List methods() { return methods; } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code pkg} attribute */ @Override public Models.Pkg pkg() { return pkg; } /** * Copy the current immutable object with elements that replace the content of {@link Model.AnnotationType#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.AnnotationType withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.AnnotationType( newValue, this.declaringType, this.declaredTypes, this.methods, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.AnnotationType#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.AnnotationType withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.AnnotationType( newValue, this.declaringType, this.declaredTypes, this.methods, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.AnnotationType#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.AnnotationType withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.AnnotationType( this.annotations, newValue, this.declaredTypes, this.methods, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting an optional value for the {@link Model.AnnotationType#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.AnnotationType withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.AnnotationType(this.annotations, value, this.declaredTypes, this.methods, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.AnnotationType#declaredTypes() declaredTypes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.AnnotationType withDeclaredTypes(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.AnnotationType( this.annotations, this.declaringType, newValue, this.methods, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.AnnotationType#declaredTypes() declaredTypes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of declaredTypes elements to set * @return A modified copy of {@code this} object */ public final Models.AnnotationType withDeclaredTypes(Iterable elements) { if (this.declaredTypes == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.AnnotationType( this.annotations, this.declaringType, newValue, this.methods, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.AnnotationType#methods() methods}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.AnnotationType withMethods(Model.Method... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.AnnotationType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.AnnotationType#methods() methods}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of methods elements to set * @return A modified copy of {@code this} object */ public final Models.AnnotationType withMethods(Iterable elements) { if (this.methods == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.AnnotationType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.AnnotationType#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.AnnotationType withModifier(int value) { if (this.modifier == value) return this; return new Models.AnnotationType( this.annotations, this.declaringType, this.declaredTypes, this.methods, value, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.AnnotationType#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.AnnotationType withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.AnnotationType( this.annotations, this.declaringType, this.declaredTypes, this.methods, this.modifier, newValue, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.AnnotationType#pkg() pkg} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for pkg * @return A modified copy of the {@code this} object */ public final Models.AnnotationType withPkg(Model.Pkg value) { if (this.pkg == value) return this; Models.Pkg newValue = Models.Pkg.copyOf(value); return new Models.AnnotationType( this.annotations, this.declaringType, this.declaredTypes, this.methods, this.modifier, this.name, newValue); } /** * This instance is equal to all instances of {@code AnnotationType} 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 Models.AnnotationType && equalTo(0, (Models.AnnotationType) another); } private boolean equalTo(int synthetic, Models.AnnotationType another) { return annotations.equals(another.annotations) && Objects.equals(declaringType, another.declaringType) && declaredTypes.equals(another.declaredTypes) && methods.equals(another.methods) && modifier == another.modifier && name.equals(another.name) && pkg.equals(another.pkg); } /** * Computes a hash code from attributes: {@code annotations}, {@code declaringType}, {@code declaredTypes}, {@code methods}, {@code modifier}, {@code name}, {@code pkg}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + declaredTypes.hashCode(); h += (h << 5) + methods.hashCode(); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); h += (h << 5) + pkg.hashCode(); return h; } /** * Prints the immutable value {@code AnnotationType} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("AnnotationType{"); builder.append("annotations=").append(annotations); if (declaringType != null) { builder.append(", "); builder.append("declaringType=").append(declaringType); } builder.append(", "); builder.append("declaredTypes=").append(declaredTypes); builder.append(", "); builder.append("methods=").append(methods); builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); builder.append(", "); builder.append("pkg=").append(pkg); return builder.append("}").toString(); } /** * Construct a new immutable {@code AnnotationType} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @param pkg The value for the {@code pkg} attribute * @return An immutable AnnotationType instance */ public static Models.AnnotationType of(int modifier, String name, Model.Pkg pkg) { return new Models.AnnotationType(modifier, name, pkg); } /** * Creates an immutable copy of a {@link Model.AnnotationType} 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 AnnotationType instance */ public static Models.AnnotationType copyOf(Model.AnnotationType instance) { if (instance instanceof Models.AnnotationType) { return (Models.AnnotationType) instance; } return Models.AnnotationType.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.AnnotationType AnnotationType}. *

     * Models.AnnotationType.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.AnnotationType#annotations() annotations} elements
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.AnnotationType#declaringType() declaringType}
     *    .addDeclaredTypes|addAllDeclaredTypes(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.AnnotationType#declaredTypes() declaredTypes} elements
     *    .addMethods|addAllMethods(cn.zenliu.units.codegen.model.Model.Method) // {@link Model.AnnotationType#methods() methods} elements
     *    .modifier(int) // required {@link Model.AnnotationType#modifier() modifier}
     *    .name(String) // required {@link Model.AnnotationType#name() name}
     *    .pkg(cn.zenliu.units.codegen.model.Model.Pkg) // required {@link Model.AnnotationType#pkg() pkg}
     *    .build();
     * 
* @return A new AnnotationType builder */ public static Models.AnnotationType.Builder builder() { return new Models.AnnotationType.Builder(); } /** * Builds instances of type {@link Models.AnnotationType AnnotationType}. * 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 = "Model.AnnotationType", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private static final long INIT_BIT_PKG = 0x4L; private long initBits = 0x7L; private List annotations = new ArrayList(); private @Nullable Model.Type declaringType; private List declaredTypes = new ArrayList(); private List methods = new ArrayList(); private int modifier; private @Nullable String name; private @Nullable Model.Pkg pkg; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.AnnotationType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.AnnotationType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaredTypes} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaredTypes instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Type} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Type instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Package} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Package instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.MethodHolder} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.MethodHolder instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.AnnotationType) { Model.AnnotationType instance = (Model.AnnotationType) object; if ((bits & 0x1L) == 0) { addAllMethods(instance.methods()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } if ((bits & 0x20L) == 0) { name(instance.name()); bits |= 0x20L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x40L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x40L; } } if (object instanceof Model.With.DeclaredTypes) { Model.With.DeclaredTypes instance = (Model.With.DeclaredTypes) object; if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } } if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x40L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x40L; } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x20L) == 0) { name(instance.name()); bits |= 0x20L; } } if (object instanceof Model.Type) { Model.Type instance = (Model.Type) object; if ((bits & 0x20L) == 0) { name(instance.name()); bits |= 0x20L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x40L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x40L; } if ((bits & 0x2L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } } if (object instanceof Model.With.Package) { Model.With.Package instance = (Model.With.Package) object; if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } } if (object instanceof Model.With.MethodHolder) { Model.With.MethodHolder instance = (Model.With.MethodHolder) object; if ((bits & 0x1L) == 0) { addAllMethods(instance.methods()); bits |= 0x1L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x4L) == 0) { modifier(instance.modifier()); bits |= 0x4L; } } } /** * Adds one element to {@link Model.AnnotationType#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.AnnotationType#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.AnnotationType#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.AnnotationType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.AnnotationType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the optional value {@link Model.AnnotationType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.AnnotationType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Adds one element to {@link Model.AnnotationType#declaredTypes() declaredTypes} list. * @param element A declaredTypes element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type element) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); return this; } /** * Adds elements to {@link Model.AnnotationType#declaredTypes() declaredTypes} list. * @param elements An array of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type... elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Sets or replaces all elements for {@link Model.AnnotationType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaredTypes(Iterable elements) { this.declaredTypes.clear(); return addAllDeclaredTypes(elements); } /** * Adds elements to {@link Model.AnnotationType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllDeclaredTypes(Iterable elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Adds one element to {@link Model.AnnotationType#methods() methods} list. * @param element A methods element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMethods(Model.Method element) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); return this; } /** * Constructs and adds an element for the {@link Model.AnnotationType#methods() methods} list. * @param modifier The value for {@code methods.modifier} * @param name The value for {@code methods.name} * @return {@code this} builder for use in a chained invocation */ public final Builder addMethods(int modifier, String name) { return addMethods(Models.Method.of(modifier, name)); } /** * Adds elements to {@link Model.AnnotationType#methods() methods} list. * @param elements An array of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addMethods(Model.Method... elements) { for (Model.Method element : elements) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); } return this; } /** * Sets or replaces all elements for {@link Model.AnnotationType#methods() methods} list. * @param elements An iterable of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder methods(Iterable elements) { this.methods.clear(); return addAllMethods(elements); } /** * Adds elements to {@link Model.AnnotationType#methods() methods} list. * @param elements An iterable of methods elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllMethods(Iterable elements) { for (Model.Method element : elements) { element = Models.Method.copyOf(element); this.methods.add(Objects.requireNonNull(element, "methods element")); } return this; } /** * Initializes the value for the {@link Model.AnnotationType#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.AnnotationType#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Constructs and initializes the value for the {@link Model.AnnotationType#pkg() pkg} attribute. * @param name The value for {@code pkg.name} * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(String name) { return pkg(Models.Pkg.of(name)); } /** * Initializes the value for the {@link Model.AnnotationType#pkg() pkg} attribute. * @param pkg The value for pkg * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(Model.Pkg pkg) { this.pkg = Models.Pkg.copyOf(pkg); initBits &= ~INIT_BIT_PKG; return this; } /** * Builds a new {@link Models.AnnotationType AnnotationType}. * @return An immutable instance of AnnotationType * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.AnnotationType build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.AnnotationType( createUnmodifiableList(true, annotations), declaringType, createUnmodifiableList(true, declaredTypes), createUnmodifiableList(true, methods), modifier, name, Models.Pkg.copyOf(pkg)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_PKG) != 0) attributes.add("pkg"); return "Cannot build AnnotationType, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.Method}. *

* Use the builder to create immutable instances: * {@code Models.Method.builder()}. * Use the static factory method to create immutable instances: * {@code Models.Method.of()}. */ @Generated(from = "Model.Method", generator = "Immutables") @Immutable @CheckReturnValue public static final class Method implements Model.Method { private final List annotations; private final List typeVars; private final @Nullable Model.Type declaringType; private final int modifier; private final String name; private final List parameters; private final @Nullable Model.Type returnType; private Method(int modifier, String name) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.annotations = Collections.emptyList(); this.typeVars = Collections.emptyList(); this.declaringType = null; this.parameters = Collections.emptyList(); this.returnType = null; } private Method( List annotations, List typeVars, @Nullable Model.Type declaringType, int modifier, String name, List parameters, @Nullable Model.Type returnType) { this.annotations = annotations; this.typeVars = typeVars; this.declaringType = declaringType; this.modifier = modifier; this.name = name; this.parameters = parameters; this.returnType = returnType; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code typeVars} attribute */ @Override public List typeVars() { return typeVars; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code parameters} attribute */ @Override public List parameters() { return parameters; } /** * @return The value of the {@code returnType} attribute */ @Override public Optional returnType() { return Optional.ofNullable(returnType); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Method#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.Method withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.Method( newValue, this.typeVars, this.declaringType, this.modifier, this.name, this.parameters, this.returnType); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Method#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.Method withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.Method( newValue, this.typeVars, this.declaringType, this.modifier, this.name, this.parameters, this.returnType); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Method#typeVars() typeVars}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.Method withTypeVars(Model.TypeVar... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.Method( this.annotations, newValue, this.declaringType, this.modifier, this.name, this.parameters, this.returnType); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Method#typeVars() typeVars}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of typeVars elements to set * @return A modified copy of {@code this} object */ public final Models.Method withTypeVars(Iterable elements) { if (this.typeVars == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.Method( this.annotations, newValue, this.declaringType, this.modifier, this.name, this.parameters, this.returnType); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.Method#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.Method withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.Method( this.annotations, this.typeVars, newValue, this.modifier, this.name, this.parameters, this.returnType); } /** * Copy the current immutable object by setting an optional value for the {@link Model.Method#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.Method withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.Method( this.annotations, this.typeVars, value, this.modifier, this.name, this.parameters, this.returnType); } /** * Copy the current immutable object by setting a value for the {@link Model.Method#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.Method withModifier(int value) { if (this.modifier == value) return this; return new Models.Method( this.annotations, this.typeVars, this.declaringType, value, this.name, this.parameters, this.returnType); } /** * Copy the current immutable object by setting a value for the {@link Model.Method#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.Method withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.Method( this.annotations, this.typeVars, this.declaringType, this.modifier, newValue, this.parameters, this.returnType); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Method#parameters() parameters}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.Method withParameters(Model.Parameter... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.Method( this.annotations, this.typeVars, this.declaringType, this.modifier, this.name, newValue, this.returnType); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Method#parameters() parameters}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of parameters elements to set * @return A modified copy of {@code this} object */ public final Models.Method withParameters(Iterable elements) { if (this.parameters == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.Method( this.annotations, this.typeVars, this.declaringType, this.modifier, this.name, newValue, this.returnType); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.Method#returnType() returnType} attribute. * @param value The value for returnType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.Method withReturnType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.returnType == newValue) return this; return new Models.Method( this.annotations, this.typeVars, this.declaringType, this.modifier, this.name, this.parameters, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link Model.Method#returnType() returnType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for returnType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.Method withReturnType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.returnType == value) return this; return new Models.Method( this.annotations, this.typeVars, this.declaringType, this.modifier, this.name, this.parameters, value); } /** * This instance is equal to all instances of {@code Method} 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 Models.Method && equalTo(0, (Models.Method) another); } private boolean equalTo(int synthetic, Models.Method another) { return annotations.equals(another.annotations) && typeVars.equals(another.typeVars) && Objects.equals(declaringType, another.declaringType) && modifier == another.modifier && name.equals(another.name) && parameters.equals(another.parameters) && Objects.equals(returnType, another.returnType); } /** * Computes a hash code from attributes: {@code annotations}, {@code typeVars}, {@code declaringType}, {@code modifier}, {@code name}, {@code parameters}, {@code returnType}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + typeVars.hashCode(); h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); h += (h << 5) + parameters.hashCode(); h += (h << 5) + Objects.hashCode(returnType); return h; } /** * Prints the immutable value {@code Method} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("Method{"); builder.append("annotations=").append(annotations); builder.append(", "); builder.append("typeVars=").append(typeVars); if (declaringType != null) { builder.append(", "); builder.append("declaringType=").append(declaringType); } builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); builder.append(", "); builder.append("parameters=").append(parameters); if (returnType != null) { builder.append(", "); builder.append("returnType=").append(returnType); } return builder.append("}").toString(); } /** * Construct a new immutable {@code Method} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @return An immutable Method instance */ public static Models.Method of(int modifier, String name) { return new Models.Method(modifier, name); } /** * Creates an immutable copy of a {@link Model.Method} 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 Method instance */ public static Models.Method copyOf(Model.Method instance) { if (instance instanceof Models.Method) { return (Models.Method) instance; } return Models.Method.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.Method Method}. *

     * Models.Method.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.Method#annotations() annotations} elements
     *    .addTypeVars|addAllTypeVars(cn.zenliu.units.codegen.model.Model.TypeVar) // {@link Model.Method#typeVars() typeVars} elements
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.Method#declaringType() declaringType}
     *    .modifier(int) // required {@link Model.Method#modifier() modifier}
     *    .name(String) // required {@link Model.Method#name() name}
     *    .addParameters|addAllParameters(cn.zenliu.units.codegen.model.Model.Parameter) // {@link Model.Method#parameters() parameters} elements
     *    .returnType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.Method#returnType() returnType}
     *    .build();
     * 
* @return A new Method builder */ public static Models.Method.Builder builder() { return new Models.Method.Builder(); } /** * Builds instances of type {@link Models.Method Method}. * 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 = "Model.Method", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private long initBits = 0x3L; private List annotations = new ArrayList(); private List typeVars = new ArrayList(); private @Nullable Model.Type declaringType; private int modifier; private @Nullable String name; private List parameters = new ArrayList(); private @Nullable Model.Type returnType; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Method} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Method instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.GeneralVars} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.GeneralVars instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x10L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x10L; } } if (object instanceof Model.Method) { Model.Method instance = (Model.Method) object; if ((bits & 0x4L) == 0) { addAllTypeVars(instance.typeVars()); bits |= 0x4L; } if ((bits & 0x1L) == 0) { modifier(instance.modifier()); bits |= 0x1L; } if ((bits & 0x8L) == 0) { name(instance.name()); bits |= 0x8L; } if ((bits & 0x2L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x2L; } if ((bits & 0x10L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x10L; } addAllParameters(instance.parameters()); Optional returnTypeOptional = instance.returnType(); if (returnTypeOptional.isPresent()) { returnType(returnTypeOptional); } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x8L) == 0) { name(instance.name()); bits |= 0x8L; } } if (object instanceof Model.With.GeneralVars) { Model.With.GeneralVars instance = (Model.With.GeneralVars) object; if ((bits & 0x4L) == 0) { addAllTypeVars(instance.typeVars()); bits |= 0x4L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x2L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x2L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x1L) == 0) { modifier(instance.modifier()); bits |= 0x1L; } } } /** * Adds one element to {@link Model.Method#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.Method#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.Method#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.Method#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.Method#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Adds one element to {@link Model.Method#typeVars() typeVars} list. * @param element A typeVars element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addTypeVars(Model.TypeVar element) { element = Models.TypeVar.copyOf(element); this.typeVars.add(Objects.requireNonNull(element, "typeVars element")); return this; } /** * Constructs and adds an element for the {@link Model.Method#typeVars() typeVars} list. * @param name The value for {@code typeVars.name} * @return {@code this} builder for use in a chained invocation */ public final Builder addTypeVars(String name) { return addTypeVars(Models.TypeVar.of(name)); } /** * Adds elements to {@link Model.Method#typeVars() typeVars} list. * @param elements An array of typeVars elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addTypeVars(Model.TypeVar... elements) { for (Model.TypeVar element : elements) { element = Models.TypeVar.copyOf(element); this.typeVars.add(Objects.requireNonNull(element, "typeVars element")); } return this; } /** * Sets or replaces all elements for {@link Model.Method#typeVars() typeVars} list. * @param elements An iterable of typeVars elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder typeVars(Iterable elements) { this.typeVars.clear(); return addAllTypeVars(elements); } /** * Adds elements to {@link Model.Method#typeVars() typeVars} list. * @param elements An iterable of typeVars elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllTypeVars(Iterable elements) { for (Model.TypeVar element : elements) { element = Models.TypeVar.copyOf(element); this.typeVars.add(Objects.requireNonNull(element, "typeVars element")); } return this; } /** * Initializes the optional value {@link Model.Method#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.Method#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Initializes the value for the {@link Model.Method#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.Method#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Adds one element to {@link Model.Method#parameters() parameters} list. * @param element A parameters element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addParameters(Model.Parameter element) { element = Models.Parameter.copyOf(element); this.parameters.add(Objects.requireNonNull(element, "parameters element")); return this; } /** * Constructs and adds an element for the {@link Model.Method#parameters() parameters} list. * @param modifier The value for {@code parameters.modifier} * @param name The value for {@code parameters.name} * @return {@code this} builder for use in a chained invocation */ public final Builder addParameters(int modifier, String name) { return addParameters(Models.Parameter.of(modifier, name)); } /** * Adds elements to {@link Model.Method#parameters() parameters} list. * @param elements An array of parameters elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addParameters(Model.Parameter... elements) { for (Model.Parameter element : elements) { element = Models.Parameter.copyOf(element); this.parameters.add(Objects.requireNonNull(element, "parameters element")); } return this; } /** * Sets or replaces all elements for {@link Model.Method#parameters() parameters} list. * @param elements An iterable of parameters elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder parameters(Iterable elements) { this.parameters.clear(); return addAllParameters(elements); } /** * Adds elements to {@link Model.Method#parameters() parameters} list. * @param elements An iterable of parameters elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllParameters(Iterable elements) { for (Model.Parameter element : elements) { element = Models.Parameter.copyOf(element); this.parameters.add(Objects.requireNonNull(element, "parameters element")); } return this; } /** * Initializes the optional value {@link Model.Method#returnType() returnType} to returnType. * @param returnType The value for returnType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder returnType(@Nullable Model.Type returnType) { this.returnType = returnType; return this; } /** * Initializes the optional value {@link Model.Method#returnType() returnType} to returnType. * @param returnType The value for returnType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder returnType(Optional returnType) { this.returnType = returnType.orElse(null); return this; } /** * Builds a new {@link Models.Method Method}. * @return An immutable instance of Method * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.Method build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.Method( createUnmodifiableList(true, annotations), createUnmodifiableList(true, typeVars), declaringType, modifier, name, createUnmodifiableList(true, parameters), returnType); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build Method, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.Parameter}. *

* Use the builder to create immutable instances: * {@code Models.Parameter.builder()}. * Use the static factory method to create immutable instances: * {@code Models.Parameter.of()}. */ @Generated(from = "Model.Parameter", generator = "Immutables") @Immutable @CheckReturnValue public static final class Parameter implements Model.Parameter { private final List annotations; private final @Nullable Model.Type type; private final int modifier; private final String name; private Parameter(int modifier, String name) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.annotations = Collections.emptyList(); this.type = null; } private Parameter( List annotations, @Nullable Model.Type type, int modifier, String name) { this.annotations = annotations; this.type = type; this.modifier = modifier; this.name = name; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code type} attribute */ @Override public Optional type() { return Optional.ofNullable(type); } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * Copy the current immutable object with elements that replace the content of {@link Model.Parameter#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.Parameter withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.Parameter(newValue, this.type, this.modifier, this.name); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Parameter#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.Parameter withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.Parameter(newValue, this.type, this.modifier, this.name); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.Parameter#type() type} attribute. * @param value The value for type, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.Parameter withType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.type == newValue) return this; return new Models.Parameter(this.annotations, newValue, this.modifier, this.name); } /** * Copy the current immutable object by setting an optional value for the {@link Model.Parameter#type() type} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for type * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.Parameter withType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.type == value) return this; return new Models.Parameter(this.annotations, value, this.modifier, this.name); } /** * Copy the current immutable object by setting a value for the {@link Model.Parameter#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.Parameter withModifier(int value) { if (this.modifier == value) return this; return new Models.Parameter(this.annotations, this.type, value, this.name); } /** * Copy the current immutable object by setting a value for the {@link Model.Parameter#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.Parameter withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.Parameter(this.annotations, this.type, this.modifier, newValue); } /** * This instance is equal to all instances of {@code Parameter} 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 Models.Parameter && equalTo(0, (Models.Parameter) another); } private boolean equalTo(int synthetic, Models.Parameter another) { return annotations.equals(another.annotations) && Objects.equals(type, another.type) && modifier == another.modifier && name.equals(another.name); } /** * Computes a hash code from attributes: {@code annotations}, {@code type}, {@code modifier}, {@code name}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + Objects.hashCode(type); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); return h; } /** * Prints the immutable value {@code Parameter} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("Parameter{"); builder.append("annotations=").append(annotations); if (type != null) { builder.append(", "); builder.append("type=").append(type); } builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); return builder.append("}").toString(); } /** * Construct a new immutable {@code Parameter} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @return An immutable Parameter instance */ public static Models.Parameter of(int modifier, String name) { return new Models.Parameter(modifier, name); } /** * Creates an immutable copy of a {@link Model.Parameter} 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 Parameter instance */ public static Models.Parameter copyOf(Model.Parameter instance) { if (instance instanceof Models.Parameter) { return (Models.Parameter) instance; } return Models.Parameter.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.Parameter Parameter}. *

     * Models.Parameter.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.Parameter#annotations() annotations} elements
     *    .type(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.Parameter#type() type}
     *    .modifier(int) // required {@link Model.Parameter#modifier() modifier}
     *    .name(String) // required {@link Model.Parameter#name() name}
     *    .build();
     * 
* @return A new Parameter builder */ public static Models.Parameter.Builder builder() { return new Models.Parameter.Builder(); } /** * Builds instances of type {@link Models.Parameter Parameter}. * 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 = "Model.Parameter", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private long initBits = 0x3L; private List annotations = new ArrayList(); private @Nullable Model.Type type; private int modifier; private @Nullable String name; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Type} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Type instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Parameter} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Parameter instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.Type) { Model.With.Type instance = (Model.With.Type) object; if ((bits & 0x4L) == 0) { Optional typeOptional = instance.type(); if (typeOptional.isPresent()) { type(typeOptional); } bits |= 0x4L; } } if (object instanceof Model.Parameter) { Model.Parameter instance = (Model.Parameter) object; if ((bits & 0x8L) == 0) { name(instance.name()); bits |= 0x8L; } if ((bits & 0x2L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { Optional typeOptional = instance.type(); if (typeOptional.isPresent()) { type(typeOptional); } bits |= 0x4L; } if ((bits & 0x1L) == 0) { modifier(instance.modifier()); bits |= 0x1L; } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x8L) == 0) { name(instance.name()); bits |= 0x8L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x2L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x2L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x1L) == 0) { modifier(instance.modifier()); bits |= 0x1L; } } } /** * Adds one element to {@link Model.Parameter#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.Parameter#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.Parameter#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.Parameter#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.Parameter#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the optional value {@link Model.Parameter#type() type} to type. * @param type The value for type, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder type(@Nullable Model.Type type) { this.type = type; return this; } /** * Initializes the optional value {@link Model.Parameter#type() type} to type. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder type(Optional type) { this.type = type.orElse(null); return this; } /** * Initializes the value for the {@link Model.Parameter#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.Parameter#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Builds a new {@link Models.Parameter Parameter}. * @return An immutable instance of Parameter * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.Parameter build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.Parameter(createUnmodifiableList(true, annotations), type, modifier, name); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build Parameter, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.Field}. *

* Use the builder to create immutable instances: * {@code Models.Field.builder()}. * Use the static factory method to create immutable instances: * {@code Models.Field.of()}. */ @Generated(from = "Model.Field", generator = "Immutables") @Immutable @CheckReturnValue public static final class Field implements Model.Field { private final List annotations; private final @Nullable Model.Type declaringType; private final int modifier; private final String name; private final Model.Type type; private Field(int modifier, String name, Model.Type type) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.type = Objects.requireNonNull(type, "type"); this.annotations = Collections.emptyList(); this.declaringType = null; } private Field( List annotations, @Nullable Model.Type declaringType, int modifier, String name, Model.Type type) { this.annotations = annotations; this.declaringType = declaringType; this.modifier = modifier; this.name = name; this.type = type; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code type} attribute */ @Override public Model.Type type() { return type; } /** * Copy the current immutable object with elements that replace the content of {@link Model.Field#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.Field withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.Field(newValue, this.declaringType, this.modifier, this.name, this.type); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Field#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.Field withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.Field(newValue, this.declaringType, this.modifier, this.name, this.type); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.Field#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.Field withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.Field(this.annotations, newValue, this.modifier, this.name, this.type); } /** * Copy the current immutable object by setting an optional value for the {@link Model.Field#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.Field withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.Field(this.annotations, value, this.modifier, this.name, this.type); } /** * Copy the current immutable object by setting a value for the {@link Model.Field#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.Field withModifier(int value) { if (this.modifier == value) return this; return new Models.Field(this.annotations, this.declaringType, value, this.name, this.type); } /** * Copy the current immutable object by setting a value for the {@link Model.Field#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.Field withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.Field(this.annotations, this.declaringType, this.modifier, newValue, this.type); } /** * Copy the current immutable object by setting a value for the {@link Model.Field#type() type} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for type * @return A modified copy of the {@code this} object */ public final Models.Field withType(Model.Type value) { if (this.type == value) return this; Model.Type newValue = Objects.requireNonNull(value, "type"); return new Models.Field(this.annotations, this.declaringType, this.modifier, this.name, newValue); } /** * This instance is equal to all instances of {@code Field} 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 Models.Field && equalTo(0, (Models.Field) another); } private boolean equalTo(int synthetic, Models.Field another) { return annotations.equals(another.annotations) && Objects.equals(declaringType, another.declaringType) && modifier == another.modifier && name.equals(another.name) && type.equals(another.type); } /** * Computes a hash code from attributes: {@code annotations}, {@code declaringType}, {@code modifier}, {@code name}, {@code type}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); h += (h << 5) + type.hashCode(); return h; } /** * Prints the immutable value {@code Field} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("Field{"); builder.append("annotations=").append(annotations); if (declaringType != null) { builder.append(", "); builder.append("declaringType=").append(declaringType); } builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); builder.append(", "); builder.append("type=").append(type); return builder.append("}").toString(); } /** * Construct a new immutable {@code Field} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @param type The value for the {@code type} attribute * @return An immutable Field instance */ public static Models.Field of(int modifier, String name, Model.Type type) { return new Models.Field(modifier, name, type); } /** * Creates an immutable copy of a {@link Model.Field} 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 Field instance */ public static Models.Field copyOf(Model.Field instance) { if (instance instanceof Models.Field) { return (Models.Field) instance; } return Models.Field.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.Field Field}. *

     * Models.Field.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.Field#annotations() annotations} elements
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.Field#declaringType() declaringType}
     *    .modifier(int) // required {@link Model.Field#modifier() modifier}
     *    .name(String) // required {@link Model.Field#name() name}
     *    .type(cn.zenliu.units.codegen.model.Model.Type) // required {@link Model.Field#type() type}
     *    .build();
     * 
* @return A new Field builder */ public static Models.Field.Builder builder() { return new Models.Field.Builder(); } /** * Builds instances of type {@link Models.Field Field}. * 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 = "Model.Field", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private static final long INIT_BIT_TYPE = 0x4L; private long initBits = 0x7L; private List annotations = new ArrayList(); private @Nullable Model.Type declaringType; private int modifier; private @Nullable String name; private @Nullable Model.Type type; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Field} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Field instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x8L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x8L; } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x4L) == 0) { name(instance.name()); bits |= 0x4L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x2L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x2L; } } if (object instanceof Model.Field) { Model.Field instance = (Model.Field) object; if ((bits & 0x4L) == 0) { name(instance.name()); bits |= 0x4L; } if ((bits & 0x2L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x2L; } type(instance.type()); if ((bits & 0x8L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x8L; } if ((bits & 0x1L) == 0) { modifier(instance.modifier()); bits |= 0x1L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x1L) == 0) { modifier(instance.modifier()); bits |= 0x1L; } } } /** * Adds one element to {@link Model.Field#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.Field#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.Field#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.Field#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.Field#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the optional value {@link Model.Field#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.Field#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Initializes the value for the {@link Model.Field#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.Field#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Initializes the value for the {@link Model.Field#type() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder type(Model.Type type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return this; } /** * Builds a new {@link Models.Field Field}. * @return An immutable instance of Field * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.Field build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.Field(createUnmodifiableList(true, annotations), declaringType, modifier, name, type); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_TYPE) != 0) attributes.add("type"); return "Cannot build Field, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.GenericType}. *

* Use the builder to create immutable instances: * {@code Models.GenericType.builder()}. * Use the static factory method to create immutable instances: * {@code Models.GenericType.of()}. */ @Generated(from = "Model.GenericType", generator = "Immutables") @Immutable @CheckReturnValue public static final class GenericType implements Model.GenericType { private final List annotations; private final @Nullable Model.Type declaringType; private final List declaredTypes; private final List typeVars; private final int modifier; private final String name; private final Models.Pkg pkg; private GenericType(int modifier, String name, Model.Pkg pkg) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.pkg = Models.Pkg.copyOf(pkg); this.annotations = Collections.emptyList(); this.declaringType = null; this.declaredTypes = Collections.emptyList(); this.typeVars = Collections.emptyList(); } private GenericType( List annotations, @Nullable Model.Type declaringType, List declaredTypes, List typeVars, int modifier, String name, Models.Pkg pkg) { this.annotations = annotations; this.declaringType = declaringType; this.declaredTypes = declaredTypes; this.typeVars = typeVars; this.modifier = modifier; this.name = name; this.pkg = pkg; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code declaredTypes} attribute */ @Override public List declaredTypes() { return declaredTypes; } /** * @return The value of the {@code typeVars} attribute */ @Override public List typeVars() { return typeVars; } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code pkg} attribute */ @Override public Models.Pkg pkg() { return pkg; } /** * Copy the current immutable object with elements that replace the content of {@link Model.GenericType#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.GenericType withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.GenericType( newValue, this.declaringType, this.declaredTypes, this.typeVars, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.GenericType#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.GenericType withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.GenericType( newValue, this.declaringType, this.declaredTypes, this.typeVars, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.GenericType#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.GenericType withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.GenericType( this.annotations, newValue, this.declaredTypes, this.typeVars, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting an optional value for the {@link Model.GenericType#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.GenericType withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.GenericType( this.annotations, value, this.declaredTypes, this.typeVars, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.GenericType#declaredTypes() declaredTypes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.GenericType withDeclaredTypes(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.GenericType( this.annotations, this.declaringType, newValue, this.typeVars, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.GenericType#declaredTypes() declaredTypes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of declaredTypes elements to set * @return A modified copy of {@code this} object */ public final Models.GenericType withDeclaredTypes(Iterable elements) { if (this.declaredTypes == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.GenericType( this.annotations, this.declaringType, newValue, this.typeVars, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.GenericType#typeVars() typeVars}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.GenericType withTypeVars(Model.TypeVar... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.GenericType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.GenericType#typeVars() typeVars}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of typeVars elements to set * @return A modified copy of {@code this} object */ public final Models.GenericType withTypeVars(Iterable elements) { if (this.typeVars == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.GenericType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.GenericType#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.GenericType withModifier(int value) { if (this.modifier == value) return this; return new Models.GenericType( this.annotations, this.declaringType, this.declaredTypes, this.typeVars, value, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.GenericType#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.GenericType withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.GenericType( this.annotations, this.declaringType, this.declaredTypes, this.typeVars, this.modifier, newValue, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.GenericType#pkg() pkg} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for pkg * @return A modified copy of the {@code this} object */ public final Models.GenericType withPkg(Model.Pkg value) { if (this.pkg == value) return this; Models.Pkg newValue = Models.Pkg.copyOf(value); return new Models.GenericType( this.annotations, this.declaringType, this.declaredTypes, this.typeVars, this.modifier, this.name, newValue); } /** * This instance is equal to all instances of {@code GenericType} 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 Models.GenericType && equalTo(0, (Models.GenericType) another); } private boolean equalTo(int synthetic, Models.GenericType another) { return annotations.equals(another.annotations) && Objects.equals(declaringType, another.declaringType) && declaredTypes.equals(another.declaredTypes) && typeVars.equals(another.typeVars) && modifier == another.modifier && name.equals(another.name) && pkg.equals(another.pkg); } /** * Computes a hash code from attributes: {@code annotations}, {@code declaringType}, {@code declaredTypes}, {@code typeVars}, {@code modifier}, {@code name}, {@code pkg}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + declaredTypes.hashCode(); h += (h << 5) + typeVars.hashCode(); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); h += (h << 5) + pkg.hashCode(); return h; } /** * Prints the immutable value {@code GenericType} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("GenericType{"); builder.append("annotations=").append(annotations); if (declaringType != null) { builder.append(", "); builder.append("declaringType=").append(declaringType); } builder.append(", "); builder.append("declaredTypes=").append(declaredTypes); builder.append(", "); builder.append("typeVars=").append(typeVars); builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); builder.append(", "); builder.append("pkg=").append(pkg); return builder.append("}").toString(); } /** * Construct a new immutable {@code GenericType} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @param pkg The value for the {@code pkg} attribute * @return An immutable GenericType instance */ public static Models.GenericType of(int modifier, String name, Model.Pkg pkg) { return new Models.GenericType(modifier, name, pkg); } /** * Creates an immutable copy of a {@link Model.GenericType} 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 GenericType instance */ public static Models.GenericType copyOf(Model.GenericType instance) { if (instance instanceof Models.GenericType) { return (Models.GenericType) instance; } return Models.GenericType.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.GenericType GenericType}. *

     * Models.GenericType.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.GenericType#annotations() annotations} elements
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.GenericType#declaringType() declaringType}
     *    .addDeclaredTypes|addAllDeclaredTypes(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.GenericType#declaredTypes() declaredTypes} elements
     *    .addTypeVars|addAllTypeVars(cn.zenliu.units.codegen.model.Model.TypeVar) // {@link Model.GenericType#typeVars() typeVars} elements
     *    .modifier(int) // required {@link Model.GenericType#modifier() modifier}
     *    .name(String) // required {@link Model.GenericType#name() name}
     *    .pkg(cn.zenliu.units.codegen.model.Model.Pkg) // required {@link Model.GenericType#pkg() pkg}
     *    .build();
     * 
* @return A new GenericType builder */ public static Models.GenericType.Builder builder() { return new Models.GenericType.Builder(); } /** * Builds instances of type {@link Models.GenericType GenericType}. * 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 = "Model.GenericType", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private static final long INIT_BIT_PKG = 0x4L; private long initBits = 0x7L; private List annotations = new ArrayList(); private @Nullable Model.Type declaringType; private List declaredTypes = new ArrayList(); private List typeVars = new ArrayList(); private int modifier; private @Nullable String name; private @Nullable Model.Pkg pkg; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaredTypes} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaredTypes instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.GenericType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.GenericType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Type} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Type instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.GeneralVars} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.GeneralVars instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Package} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Package instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.RawGenericType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.RawGenericType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.DeclaredTypes) { Model.With.DeclaredTypes instance = (Model.With.DeclaredTypes) object; if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } } if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x40L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x40L; } } if (object instanceof Model.GenericType) { Model.GenericType instance = (Model.GenericType) object; if ((bits & 0x10L) == 0) { addAllTypeVars(instance.typeVars()); bits |= 0x10L; } if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } if ((bits & 0x20L) == 0) { name(instance.name()); bits |= 0x20L; } if ((bits & 0x4L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x4L; } if ((bits & 0x8L) == 0) { pkg(instance.pkg()); bits |= 0x8L; } if ((bits & 0x40L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x40L; } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x20L) == 0) { name(instance.name()); bits |= 0x20L; } } if (object instanceof Model.Type) { Model.Type instance = (Model.Type) object; if ((bits & 0x20L) == 0) { name(instance.name()); bits |= 0x20L; } if ((bits & 0x4L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x4L; } if ((bits & 0x8L) == 0) { pkg(instance.pkg()); bits |= 0x8L; } if ((bits & 0x40L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x40L; } if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } } if (object instanceof Model.With.GeneralVars) { Model.With.GeneralVars instance = (Model.With.GeneralVars) object; if ((bits & 0x10L) == 0) { addAllTypeVars(instance.typeVars()); bits |= 0x10L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x4L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x4L; } } if (object instanceof Model.With.Package) { Model.With.Package instance = (Model.With.Package) object; if ((bits & 0x8L) == 0) { pkg(instance.pkg()); bits |= 0x8L; } } if (object instanceof Model.RawGenericType) { Model.RawGenericType instance = (Model.RawGenericType) object; if ((bits & 0x10L) == 0) { addAllTypeVars(instance.typeVars()); bits |= 0x10L; } if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } if ((bits & 0x20L) == 0) { name(instance.name()); bits |= 0x20L; } if ((bits & 0x4L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x4L; } if ((bits & 0x8L) == 0) { pkg(instance.pkg()); bits |= 0x8L; } if ((bits & 0x40L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x40L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } } } /** * Adds one element to {@link Model.GenericType#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.GenericType#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.GenericType#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.GenericType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.GenericType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the optional value {@link Model.GenericType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.GenericType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Adds one element to {@link Model.GenericType#declaredTypes() declaredTypes} list. * @param element A declaredTypes element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type element) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); return this; } /** * Adds elements to {@link Model.GenericType#declaredTypes() declaredTypes} list. * @param elements An array of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type... elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Sets or replaces all elements for {@link Model.GenericType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaredTypes(Iterable elements) { this.declaredTypes.clear(); return addAllDeclaredTypes(elements); } /** * Adds elements to {@link Model.GenericType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllDeclaredTypes(Iterable elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Adds one element to {@link Model.GenericType#typeVars() typeVars} list. * @param element A typeVars element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addTypeVars(Model.TypeVar element) { element = Models.TypeVar.copyOf(element); this.typeVars.add(Objects.requireNonNull(element, "typeVars element")); return this; } /** * Constructs and adds an element for the {@link Model.GenericType#typeVars() typeVars} list. * @param name The value for {@code typeVars.name} * @return {@code this} builder for use in a chained invocation */ public final Builder addTypeVars(String name) { return addTypeVars(Models.TypeVar.of(name)); } /** * Adds elements to {@link Model.GenericType#typeVars() typeVars} list. * @param elements An array of typeVars elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addTypeVars(Model.TypeVar... elements) { for (Model.TypeVar element : elements) { element = Models.TypeVar.copyOf(element); this.typeVars.add(Objects.requireNonNull(element, "typeVars element")); } return this; } /** * Sets or replaces all elements for {@link Model.GenericType#typeVars() typeVars} list. * @param elements An iterable of typeVars elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder typeVars(Iterable elements) { this.typeVars.clear(); return addAllTypeVars(elements); } /** * Adds elements to {@link Model.GenericType#typeVars() typeVars} list. * @param elements An iterable of typeVars elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllTypeVars(Iterable elements) { for (Model.TypeVar element : elements) { element = Models.TypeVar.copyOf(element); this.typeVars.add(Objects.requireNonNull(element, "typeVars element")); } return this; } /** * Initializes the value for the {@link Model.GenericType#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.GenericType#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Constructs and initializes the value for the {@link Model.GenericType#pkg() pkg} attribute. * @param name The value for {@code pkg.name} * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(String name) { return pkg(Models.Pkg.of(name)); } /** * Initializes the value for the {@link Model.GenericType#pkg() pkg} attribute. * @param pkg The value for pkg * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(Model.Pkg pkg) { this.pkg = Models.Pkg.copyOf(pkg); initBits &= ~INIT_BIT_PKG; return this; } /** * Builds a new {@link Models.GenericType GenericType}. * @return An immutable instance of GenericType * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.GenericType build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.GenericType( createUnmodifiableList(true, annotations), declaringType, createUnmodifiableList(true, declaredTypes), createUnmodifiableList(true, typeVars), modifier, name, Models.Pkg.copyOf(pkg)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_PKG) != 0) attributes.add("pkg"); return "Cannot build GenericType, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.ParameterizedType}. *

* Use the builder to create immutable instances: * {@code Models.ParameterizedType.builder()}. * Use the static factory method to create immutable instances: * {@code Models.ParameterizedType.of()}. */ @Generated(from = "Model.ParameterizedType", generator = "Immutables") @Immutable @CheckReturnValue public static final class ParameterizedType implements Model.ParameterizedType { private final List annotations; private final @Nullable Model.Type declaringType; private final List declaredTypes; private final List typeVars; private final List typeParams; private final int modifier; private final String name; private final Models.Pkg pkg; private ParameterizedType(int modifier, String name, Model.Pkg pkg) { this.modifier = modifier; this.name = Objects.requireNonNull(name, "name"); this.pkg = Models.Pkg.copyOf(pkg); this.annotations = Collections.emptyList(); this.declaringType = null; this.declaredTypes = Collections.emptyList(); this.typeVars = Collections.emptyList(); this.typeParams = Collections.emptyList(); } private ParameterizedType( List annotations, @Nullable Model.Type declaringType, List declaredTypes, List typeVars, List typeParams, int modifier, String name, Models.Pkg pkg) { this.annotations = annotations; this.declaringType = declaringType; this.declaredTypes = declaredTypes; this.typeVars = typeVars; this.typeParams = typeParams; this.modifier = modifier; this.name = name; this.pkg = pkg; } /** * @return The value of the {@code annotations} attribute */ @Override public List annotations() { return annotations; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code declaredTypes} attribute */ @Override public List declaredTypes() { return declaredTypes; } /** * @return The value of the {@code typeVars} attribute */ @Override public List typeVars() { return typeVars; } /** * @return The value of the {@code typeParams} attribute */ @Override public List typeParams() { return typeParams; } /** * @return The value of the {@code modifier} attribute */ @Override public int modifier() { return modifier; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code pkg} attribute */ @Override public Models.Pkg pkg() { return pkg; } /** * Copy the current immutable object with elements that replace the content of {@link Model.ParameterizedType#annotations() annotations}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.ParameterizedType withAnnotations(Model.Annotation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.ParameterizedType( newValue, this.declaringType, this.declaredTypes, this.typeVars, this.typeParams, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ParameterizedType#annotations() annotations}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of annotations elements to set * @return A modified copy of {@code this} object */ public final Models.ParameterizedType withAnnotations(Iterable elements) { if (this.annotations == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.ParameterizedType( newValue, this.declaringType, this.declaredTypes, this.typeVars, this.typeParams, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.ParameterizedType#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.ParameterizedType withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.ParameterizedType( this.annotations, newValue, this.declaredTypes, this.typeVars, this.typeParams, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting an optional value for the {@link Model.ParameterizedType#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.ParameterizedType withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.ParameterizedType( this.annotations, value, this.declaredTypes, this.typeVars, this.typeParams, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ParameterizedType#declaredTypes() declaredTypes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.ParameterizedType withDeclaredTypes(Model.Type... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.ParameterizedType( this.annotations, this.declaringType, newValue, this.typeVars, this.typeParams, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ParameterizedType#declaredTypes() declaredTypes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of declaredTypes elements to set * @return A modified copy of {@code this} object */ public final Models.ParameterizedType withDeclaredTypes(Iterable elements) { if (this.declaredTypes == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.ParameterizedType( this.annotations, this.declaringType, newValue, this.typeVars, this.typeParams, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ParameterizedType#typeVars() typeVars}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.ParameterizedType withTypeVars(Model.TypeVar... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.ParameterizedType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.typeParams, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ParameterizedType#typeVars() typeVars}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of typeVars elements to set * @return A modified copy of {@code this} object */ public final Models.ParameterizedType withTypeVars(Iterable elements) { if (this.typeVars == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.ParameterizedType( this.annotations, this.declaringType, this.declaredTypes, newValue, this.typeParams, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ParameterizedType#typeParams() typeParams}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.ParameterizedType withTypeParams(Model.TypeParam... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.ParameterizedType( this.annotations, this.declaringType, this.declaredTypes, this.typeVars, newValue, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object with elements that replace the content of {@link Model.ParameterizedType#typeParams() typeParams}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of typeParams elements to set * @return A modified copy of {@code this} object */ public final Models.ParameterizedType withTypeParams(Iterable elements) { if (this.typeParams == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.ParameterizedType( this.annotations, this.declaringType, this.declaredTypes, this.typeVars, newValue, this.modifier, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.ParameterizedType#modifier() modifier} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for modifier * @return A modified copy of the {@code this} object */ public final Models.ParameterizedType withModifier(int value) { if (this.modifier == value) return this; return new Models.ParameterizedType( this.annotations, this.declaringType, this.declaredTypes, this.typeVars, this.typeParams, value, this.name, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.ParameterizedType#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.ParameterizedType withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.ParameterizedType( this.annotations, this.declaringType, this.declaredTypes, this.typeVars, this.typeParams, this.modifier, newValue, this.pkg); } /** * Copy the current immutable object by setting a value for the {@link Model.ParameterizedType#pkg() pkg} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for pkg * @return A modified copy of the {@code this} object */ public final Models.ParameterizedType withPkg(Model.Pkg value) { if (this.pkg == value) return this; Models.Pkg newValue = Models.Pkg.copyOf(value); return new Models.ParameterizedType( this.annotations, this.declaringType, this.declaredTypes, this.typeVars, this.typeParams, this.modifier, this.name, newValue); } /** * This instance is equal to all instances of {@code ParameterizedType} 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 Models.ParameterizedType && equalTo(0, (Models.ParameterizedType) another); } private boolean equalTo(int synthetic, Models.ParameterizedType another) { return annotations.equals(another.annotations) && Objects.equals(declaringType, another.declaringType) && declaredTypes.equals(another.declaredTypes) && typeVars.equals(another.typeVars) && typeParams.equals(another.typeParams) && modifier == another.modifier && name.equals(another.name) && pkg.equals(another.pkg); } /** * Computes a hash code from attributes: {@code annotations}, {@code declaringType}, {@code declaredTypes}, {@code typeVars}, {@code typeParams}, {@code modifier}, {@code name}, {@code pkg}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + annotations.hashCode(); h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + declaredTypes.hashCode(); h += (h << 5) + typeVars.hashCode(); h += (h << 5) + typeParams.hashCode(); h += (h << 5) + modifier; h += (h << 5) + name.hashCode(); h += (h << 5) + pkg.hashCode(); return h; } /** * Prints the immutable value {@code ParameterizedType} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ParameterizedType{"); builder.append("annotations=").append(annotations); if (declaringType != null) { builder.append(", "); builder.append("declaringType=").append(declaringType); } builder.append(", "); builder.append("declaredTypes=").append(declaredTypes); builder.append(", "); builder.append("typeVars=").append(typeVars); builder.append(", "); builder.append("typeParams=").append(typeParams); builder.append(", "); builder.append("modifier=").append(modifier); builder.append(", "); builder.append("name=").append(name); builder.append(", "); builder.append("pkg=").append(pkg); return builder.append("}").toString(); } /** * Construct a new immutable {@code ParameterizedType} instance. * @param modifier The value for the {@code modifier} attribute * @param name The value for the {@code name} attribute * @param pkg The value for the {@code pkg} attribute * @return An immutable ParameterizedType instance */ public static Models.ParameterizedType of(int modifier, String name, Model.Pkg pkg) { return new Models.ParameterizedType(modifier, name, pkg); } /** * Creates an immutable copy of a {@link Model.ParameterizedType} 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 ParameterizedType instance */ public static Models.ParameterizedType copyOf(Model.ParameterizedType instance) { if (instance instanceof Models.ParameterizedType) { return (Models.ParameterizedType) instance; } return Models.ParameterizedType.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.ParameterizedType ParameterizedType}. *

     * Models.ParameterizedType.builder()
     *    .addAnnotations|addAllAnnotations(cn.zenliu.units.codegen.model.Model.Annotation) // {@link Model.ParameterizedType#annotations() annotations} elements
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.ParameterizedType#declaringType() declaringType}
     *    .addDeclaredTypes|addAllDeclaredTypes(cn.zenliu.units.codegen.model.Model.Type) // {@link Model.ParameterizedType#declaredTypes() declaredTypes} elements
     *    .addTypeVars|addAllTypeVars(cn.zenliu.units.codegen.model.Model.TypeVar) // {@link Model.ParameterizedType#typeVars() typeVars} elements
     *    .addTypeParams|addAllTypeParams(cn.zenliu.units.codegen.model.Model.TypeParam) // {@link Model.ParameterizedType#typeParams() typeParams} elements
     *    .modifier(int) // required {@link Model.ParameterizedType#modifier() modifier}
     *    .name(String) // required {@link Model.ParameterizedType#name() name}
     *    .pkg(cn.zenliu.units.codegen.model.Model.Pkg) // required {@link Model.ParameterizedType#pkg() pkg}
     *    .build();
     * 
* @return A new ParameterizedType builder */ public static Models.ParameterizedType.Builder builder() { return new Models.ParameterizedType.Builder(); } /** * Builds instances of type {@link Models.ParameterizedType ParameterizedType}. * 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 = "Model.ParameterizedType", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MODIFIER = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private static final long INIT_BIT_PKG = 0x4L; private long initBits = 0x7L; private List annotations = new ArrayList(); private @Nullable Model.Type declaringType; private List declaredTypes = new ArrayList(); private List typeVars = new ArrayList(); private List typeParams = new ArrayList(); private int modifier; private @Nullable String name; private @Nullable Model.Pkg pkg; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaredTypes} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaredTypes instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.GeneralParams} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.GeneralParams instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.ParameterizedType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.ParameterizedType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Type} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Type instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.GeneralVars} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.GeneralVars instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Annotated} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Annotated instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Package} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Package instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.RawGenericType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.RawGenericType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Modifier} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Modifier instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.DeclaredTypes) { Model.With.DeclaredTypes instance = (Model.With.DeclaredTypes) object; if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } } if (object instanceof Model.With.GeneralParams) { Model.With.GeneralParams instance = (Model.With.GeneralParams) object; if ((bits & 0x4L) == 0) { addAllTypeParams(instance.typeParams()); bits |= 0x4L; } } if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x80L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x80L; } } if (object instanceof Model.ParameterizedType) { Model.ParameterizedType instance = (Model.ParameterizedType) object; if ((bits & 0x20L) == 0) { addAllTypeVars(instance.typeVars()); bits |= 0x20L; } if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { addAllTypeParams(instance.typeParams()); bits |= 0x4L; } if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x80L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x80L; } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } } if (object instanceof Model.Type) { Model.Type instance = (Model.Type) object; if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x80L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x80L; } if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } } if (object instanceof Model.With.GeneralVars) { Model.With.GeneralVars instance = (Model.With.GeneralVars) object; if ((bits & 0x20L) == 0) { addAllTypeVars(instance.typeVars()); bits |= 0x20L; } } if (object instanceof Model.With.Annotated) { Model.With.Annotated instance = (Model.With.Annotated) object; if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } } if (object instanceof Model.With.Package) { Model.With.Package instance = (Model.With.Package) object; if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } } if (object instanceof Model.RawGenericType) { Model.RawGenericType instance = (Model.RawGenericType) object; if ((bits & 0x20L) == 0) { addAllTypeVars(instance.typeVars()); bits |= 0x20L; } if ((bits & 0x1L) == 0) { addAllDeclaredTypes(instance.declaredTypes()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } if ((bits & 0x40L) == 0) { name(instance.name()); bits |= 0x40L; } if ((bits & 0x8L) == 0) { addAllAnnotations(instance.annotations()); bits |= 0x8L; } if ((bits & 0x10L) == 0) { pkg(instance.pkg()); bits |= 0x10L; } if ((bits & 0x80L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x80L; } } if (object instanceof Model.With.Modifier) { Model.With.Modifier instance = (Model.With.Modifier) object; if ((bits & 0x2L) == 0) { modifier(instance.modifier()); bits |= 0x2L; } } } /** * Adds one element to {@link Model.ParameterizedType#annotations() annotations} list. * @param element A annotations element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation element) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); return this; } /** * Constructs and adds an element for the {@link Model.ParameterizedType#annotations() annotations} list. * @param type The value for {@code annotations.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addAnnotations(Model.AnnotationType type) { return addAnnotations(Models.Annotation.of(type)); } /** * Adds elements to {@link Model.ParameterizedType#annotations() annotations} list. * @param elements An array of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAnnotations(Model.Annotation... elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Sets or replaces all elements for {@link Model.ParameterizedType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder annotations(Iterable elements) { this.annotations.clear(); return addAllAnnotations(elements); } /** * Adds elements to {@link Model.ParameterizedType#annotations() annotations} list. * @param elements An iterable of annotations elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAnnotations(Iterable elements) { for (Model.Annotation element : elements) { element = Models.Annotation.copyOf(element); this.annotations.add(Objects.requireNonNull(element, "annotations element")); } return this; } /** * Initializes the optional value {@link Model.ParameterizedType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.ParameterizedType#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Adds one element to {@link Model.ParameterizedType#declaredTypes() declaredTypes} list. * @param element A declaredTypes element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type element) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); return this; } /** * Adds elements to {@link Model.ParameterizedType#declaredTypes() declaredTypes} list. * @param elements An array of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addDeclaredTypes(Model.Type... elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Sets or replaces all elements for {@link Model.ParameterizedType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaredTypes(Iterable elements) { this.declaredTypes.clear(); return addAllDeclaredTypes(elements); } /** * Adds elements to {@link Model.ParameterizedType#declaredTypes() declaredTypes} list. * @param elements An iterable of declaredTypes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllDeclaredTypes(Iterable elements) { for (Model.Type element : elements) { this.declaredTypes.add(Objects.requireNonNull(element, "declaredTypes element")); } return this; } /** * Adds one element to {@link Model.ParameterizedType#typeVars() typeVars} list. * @param element A typeVars element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addTypeVars(Model.TypeVar element) { element = Models.TypeVar.copyOf(element); this.typeVars.add(Objects.requireNonNull(element, "typeVars element")); return this; } /** * Constructs and adds an element for the {@link Model.ParameterizedType#typeVars() typeVars} list. * @param name The value for {@code typeVars.name} * @return {@code this} builder for use in a chained invocation */ public final Builder addTypeVars(String name) { return addTypeVars(Models.TypeVar.of(name)); } /** * Adds elements to {@link Model.ParameterizedType#typeVars() typeVars} list. * @param elements An array of typeVars elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addTypeVars(Model.TypeVar... elements) { for (Model.TypeVar element : elements) { element = Models.TypeVar.copyOf(element); this.typeVars.add(Objects.requireNonNull(element, "typeVars element")); } return this; } /** * Sets or replaces all elements for {@link Model.ParameterizedType#typeVars() typeVars} list. * @param elements An iterable of typeVars elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder typeVars(Iterable elements) { this.typeVars.clear(); return addAllTypeVars(elements); } /** * Adds elements to {@link Model.ParameterizedType#typeVars() typeVars} list. * @param elements An iterable of typeVars elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllTypeVars(Iterable elements) { for (Model.TypeVar element : elements) { element = Models.TypeVar.copyOf(element); this.typeVars.add(Objects.requireNonNull(element, "typeVars element")); } return this; } /** * Adds one element to {@link Model.ParameterizedType#typeParams() typeParams} list. * @param element A typeParams element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addTypeParams(Model.TypeParam element) { element = Models.TypeParam.copyOf(element); this.typeParams.add(Objects.requireNonNull(element, "typeParams element")); return this; } /** * Constructs and adds an element for the {@link Model.ParameterizedType#typeParams() typeParams} list. * @param name The value for {@code typeParams.name} * @param type The value for {@code typeParams.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addTypeParams(String name, Model.Type type) { return addTypeParams(Models.TypeParam.of(name, type)); } /** * Adds elements to {@link Model.ParameterizedType#typeParams() typeParams} list. * @param elements An array of typeParams elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addTypeParams(Model.TypeParam... elements) { for (Model.TypeParam element : elements) { element = Models.TypeParam.copyOf(element); this.typeParams.add(Objects.requireNonNull(element, "typeParams element")); } return this; } /** * Sets or replaces all elements for {@link Model.ParameterizedType#typeParams() typeParams} list. * @param elements An iterable of typeParams elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder typeParams(Iterable elements) { this.typeParams.clear(); return addAllTypeParams(elements); } /** * Adds elements to {@link Model.ParameterizedType#typeParams() typeParams} list. * @param elements An iterable of typeParams elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllTypeParams(Iterable elements) { for (Model.TypeParam element : elements) { element = Models.TypeParam.copyOf(element); this.typeParams.add(Objects.requireNonNull(element, "typeParams element")); } return this; } /** * Initializes the value for the {@link Model.ParameterizedType#modifier() modifier} attribute. * @param modifier The value for modifier * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder modifier(int modifier) { this.modifier = modifier; initBits &= ~INIT_BIT_MODIFIER; return this; } /** * Initializes the value for the {@link Model.ParameterizedType#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Constructs and initializes the value for the {@link Model.ParameterizedType#pkg() pkg} attribute. * @param name The value for {@code pkg.name} * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(String name) { return pkg(Models.Pkg.of(name)); } /** * Initializes the value for the {@link Model.ParameterizedType#pkg() pkg} attribute. * @param pkg The value for pkg * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder pkg(Model.Pkg pkg) { this.pkg = Models.Pkg.copyOf(pkg); initBits &= ~INIT_BIT_PKG; return this; } /** * Builds a new {@link Models.ParameterizedType ParameterizedType}. * @return An immutable instance of ParameterizedType * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.ParameterizedType build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.ParameterizedType( createUnmodifiableList(true, annotations), declaringType, createUnmodifiableList(true, declaredTypes), createUnmodifiableList(true, typeVars), createUnmodifiableList(true, typeParams), modifier, name, Models.Pkg.copyOf(pkg)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MODIFIER) != 0) attributes.add("modifier"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_PKG) != 0) attributes.add("pkg"); return "Cannot build ParameterizedType, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.TypeVar}. *

* Use the builder to create immutable instances: * {@code Models.TypeVar.builder()}. * Use the static factory method to create immutable instances: * {@code Models.TypeVar.of()}. */ @Generated(from = "Model.TypeVar", generator = "Immutables") @Immutable @CheckReturnValue public static final class TypeVar implements Model.TypeVar { private final String name; private final List upBound; private final List lowBound; private TypeVar(String name) { this.name = Objects.requireNonNull(name, "name"); this.upBound = Collections.emptyList(); this.lowBound = Collections.emptyList(); } private TypeVar( String name, List upBound, List lowBound) { this.name = name; this.upBound = upBound; this.lowBound = lowBound; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code upBound} attribute */ @Override public List getUpBound() { return upBound; } /** * @return The value of the {@code lowBound} attribute */ @Override public List getLowBound() { return lowBound; } /** * Copy the current immutable object by setting a value for the {@link Model.TypeVar#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.TypeVar withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.TypeVar(newValue, this.upBound, this.lowBound); } /** * Copy the current immutable object with elements that replace the content of {@link Model.TypeVar#getUpBound() upBound}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.TypeVar withUpBound(Model.Generic... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.TypeVar(this.name, newValue, this.lowBound); } /** * Copy the current immutable object with elements that replace the content of {@link Model.TypeVar#getUpBound() upBound}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of upBound elements to set * @return A modified copy of {@code this} object */ public final Models.TypeVar withUpBound(Iterable elements) { if (this.upBound == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.TypeVar(this.name, newValue, this.lowBound); } /** * Copy the current immutable object with elements that replace the content of {@link Model.TypeVar#getLowBound() lowBound}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.TypeVar withLowBound(Model.Generic... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.TypeVar(this.name, this.upBound, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link Model.TypeVar#getLowBound() lowBound}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of lowBound elements to set * @return A modified copy of {@code this} object */ public final Models.TypeVar withLowBound(Iterable elements) { if (this.lowBound == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.TypeVar(this.name, this.upBound, newValue); } /** * This instance is equal to all instances of {@code TypeVar} 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 Models.TypeVar && equalTo(0, (Models.TypeVar) another); } private boolean equalTo(int synthetic, Models.TypeVar another) { return name.equals(another.name) && upBound.equals(another.upBound) && lowBound.equals(another.lowBound); } /** * Computes a hash code from attributes: {@code name}, {@code upBound}, {@code lowBound}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + upBound.hashCode(); h += (h << 5) + lowBound.hashCode(); return h; } /** * Prints the immutable value {@code TypeVar} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "TypeVar{" + "name=" + name + ", upBound=" + upBound + ", lowBound=" + lowBound + "}"; } /** * Construct a new immutable {@code TypeVar} instance. * @param name The value for the {@code name} attribute * @return An immutable TypeVar instance */ public static Models.TypeVar of(String name) { return new Models.TypeVar(name); } /** * Creates an immutable copy of a {@link Model.TypeVar} 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 TypeVar instance */ public static Models.TypeVar copyOf(Model.TypeVar instance) { if (instance instanceof Models.TypeVar) { return (Models.TypeVar) instance; } return Models.TypeVar.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.TypeVar TypeVar}. *

     * Models.TypeVar.builder()
     *    .name(String) // required {@link Model.TypeVar#name() name}
     *    .addUpBound|addAllUpBound(cn.zenliu.units.codegen.model.Model.Generic) // {@link Model.TypeVar#getUpBound() upBound} elements
     *    .addLowBound|addAllLowBound(cn.zenliu.units.codegen.model.Model.Generic) // {@link Model.TypeVar#getLowBound() lowBound} elements
     *    .build();
     * 
* @return A new TypeVar builder */ public static Models.TypeVar.Builder builder() { return new Models.TypeVar.Builder(); } /** * Builds instances of type {@link Models.TypeVar TypeVar}. * 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 = "Model.TypeVar", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_NAME = 0x1L; private long initBits = 0x1L; private @Nullable String name; private List upBound = new ArrayList(); private List lowBound = new ArrayList(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.TypeVar} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.TypeVar instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x1L) == 0) { name(instance.name()); bits |= 0x1L; } } if (object instanceof Model.TypeVar) { Model.TypeVar instance = (Model.TypeVar) object; if ((bits & 0x1L) == 0) { name(instance.name()); bits |= 0x1L; } addAllUpBound(instance.getUpBound()); addAllLowBound(instance.getLowBound()); } } /** * Initializes the value for the {@link Model.TypeVar#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Adds one element to {@link Model.TypeVar#getUpBound() upBound} list. * @param element A upBound element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addUpBound(Model.Generic element) { this.upBound.add(Objects.requireNonNull(element, "upBound element")); return this; } /** * Adds elements to {@link Model.TypeVar#getUpBound() upBound} list. * @param elements An array of upBound elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addUpBound(Model.Generic... elements) { for (Model.Generic element : elements) { this.upBound.add(Objects.requireNonNull(element, "upBound element")); } return this; } /** * Sets or replaces all elements for {@link Model.TypeVar#getUpBound() upBound} list. * @param elements An iterable of upBound elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder upBound(Iterable elements) { this.upBound.clear(); return addAllUpBound(elements); } /** * Adds elements to {@link Model.TypeVar#getUpBound() upBound} list. * @param elements An iterable of upBound elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllUpBound(Iterable elements) { for (Model.Generic element : elements) { this.upBound.add(Objects.requireNonNull(element, "upBound element")); } return this; } /** * Adds one element to {@link Model.TypeVar#getLowBound() lowBound} list. * @param element A lowBound element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addLowBound(Model.Generic element) { this.lowBound.add(Objects.requireNonNull(element, "lowBound element")); return this; } /** * Adds elements to {@link Model.TypeVar#getLowBound() lowBound} list. * @param elements An array of lowBound elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addLowBound(Model.Generic... elements) { for (Model.Generic element : elements) { this.lowBound.add(Objects.requireNonNull(element, "lowBound element")); } return this; } /** * Sets or replaces all elements for {@link Model.TypeVar#getLowBound() lowBound} list. * @param elements An iterable of lowBound elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder lowBound(Iterable elements) { this.lowBound.clear(); return addAllLowBound(elements); } /** * Adds elements to {@link Model.TypeVar#getLowBound() lowBound} list. * @param elements An iterable of lowBound elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllLowBound(Iterable elements) { for (Model.Generic element : elements) { this.lowBound.add(Objects.requireNonNull(element, "lowBound element")); } return this; } /** * Builds a new {@link Models.TypeVar TypeVar}. * @return An immutable instance of TypeVar * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.TypeVar build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.TypeVar(name, createUnmodifiableList(true, upBound), createUnmodifiableList(true, lowBound)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build TypeVar, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.TypeParam}. *

* Use the builder to create immutable instances: * {@code Models.TypeParam.builder()}. * Use the static factory method to create immutable instances: * {@code Models.TypeParam.of()}. */ @Generated(from = "Model.TypeParam", generator = "Immutables") @Immutable @CheckReturnValue public static final class TypeParam implements Model.TypeParam { private final String name; private final Model.Type type; private TypeParam(String name, Model.Type type) { this.name = Objects.requireNonNull(name, "name"); this.type = Objects.requireNonNull(type, "type"); } private TypeParam(Models.TypeParam original, String name, Model.Type type) { this.name = name; this.type = type; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code type} attribute */ @Override public Model.Type type() { return type; } /** * Copy the current immutable object by setting a value for the {@link Model.TypeParam#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.TypeParam withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.TypeParam(this, newValue, this.type); } /** * Copy the current immutable object by setting a value for the {@link Model.TypeParam#type() type} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for type * @return A modified copy of the {@code this} object */ public final Models.TypeParam withType(Model.Type value) { if (this.type == value) return this; Model.Type newValue = Objects.requireNonNull(value, "type"); return new Models.TypeParam(this, this.name, newValue); } /** * This instance is equal to all instances of {@code TypeParam} 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 Models.TypeParam && equalTo(0, (Models.TypeParam) another); } private boolean equalTo(int synthetic, Models.TypeParam another) { return name.equals(another.name) && type.equals(another.type); } /** * Computes a hash code from attributes: {@code name}, {@code type}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + type.hashCode(); return h; } /** * Prints the immutable value {@code TypeParam} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "TypeParam{" + "name=" + name + ", type=" + type + "}"; } /** * Construct a new immutable {@code TypeParam} instance. * @param name The value for the {@code name} attribute * @param type The value for the {@code type} attribute * @return An immutable TypeParam instance */ public static Models.TypeParam of(String name, Model.Type type) { return new Models.TypeParam(name, type); } /** * Creates an immutable copy of a {@link Model.TypeParam} 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 TypeParam instance */ public static Models.TypeParam copyOf(Model.TypeParam instance) { if (instance instanceof Models.TypeParam) { return (Models.TypeParam) instance; } return Models.TypeParam.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.TypeParam TypeParam}. *

     * Models.TypeParam.builder()
     *    .name(String) // required {@link Model.TypeParam#name() name}
     *    .type(cn.zenliu.units.codegen.model.Model.Type) // required {@link Model.TypeParam#type() type}
     *    .build();
     * 
* @return A new TypeParam builder */ public static Models.TypeParam.Builder builder() { return new Models.TypeParam.Builder(); } /** * Builds instances of type {@link Models.TypeParam TypeParam}. * 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 = "Model.TypeParam", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_NAME = 0x1L; private static final long INIT_BIT_TYPE = 0x2L; private long initBits = 0x3L; private @Nullable String name; private @Nullable Model.Type type; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.TypeParam} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.TypeParam instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x1L) == 0) { name(instance.name()); bits |= 0x1L; } } if (object instanceof Model.TypeParam) { Model.TypeParam instance = (Model.TypeParam) object; type(instance.type()); if ((bits & 0x1L) == 0) { name(instance.name()); bits |= 0x1L; } } } /** * Initializes the value for the {@link Model.TypeParam#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Initializes the value for the {@link Model.TypeParam#type() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder type(Model.Type type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return this; } /** * Builds a new {@link Models.TypeParam TypeParam}. * @return An immutable instance of TypeParam * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.TypeParam build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.TypeParam(null, name, type); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_TYPE) != 0) attributes.add("type"); return "Cannot build TypeParam, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.Annotation}. *

* Use the builder to create immutable instances: * {@code Models.Annotation.builder()}. * Use the static factory method to create immutable instances: * {@code Models.Annotation.of()}. */ @Generated(from = "Model.Annotation", generator = "Immutables") @Immutable @CheckReturnValue public static final class Annotation implements Model.Annotation { private final @Nullable Model.Type declaringType; private final Models.AnnotationType type; private final List values; private Annotation(Model.AnnotationType type) { this.type = Models.AnnotationType.copyOf(type); this.declaringType = null; this.values = Collections.emptyList(); } private Annotation( @Nullable Model.Type declaringType, Models.AnnotationType type, List values) { this.declaringType = declaringType; this.type = type; this.values = values; } /** * @return The value of the {@code declaringType} attribute */ @Override public Optional declaringType() { return Optional.ofNullable(declaringType); } /** * @return The value of the {@code type} attribute */ @Override public Models.AnnotationType type() { return type; } /** * @return The value of the {@code values} attribute */ @Override public List values() { return values; } /** * Copy the current immutable object by setting a present value for the optional {@link Model.Annotation#declaringType() declaringType} attribute. * @param value The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.Annotation withDeclaringType(@Nullable Model.Type value) { @Nullable Model.Type newValue = value; if (this.declaringType == newValue) return this; return new Models.Annotation(newValue, this.type, this.values); } /** * Copy the current immutable object by setting an optional value for the {@link Model.Annotation#declaringType() declaringType} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for declaringType * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.Annotation withDeclaringType(Optional optional) { @Nullable Model.Type value = optional.orElse(null); if (this.declaringType == value) return this; return new Models.Annotation(value, this.type, this.values); } /** * Copy the current immutable object by setting a value for the {@link Model.Annotation#type() type} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for type * @return A modified copy of the {@code this} object */ public final Models.Annotation withType(Model.AnnotationType value) { if (this.type == value) return this; Models.AnnotationType newValue = Models.AnnotationType.copyOf(value); return new Models.Annotation(this.declaringType, newValue, this.values); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Annotation#values() values}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final Models.Annotation withValues(Model.AnnotatedValue... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new Models.Annotation(this.declaringType, this.type, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link Model.Annotation#values() values}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of values elements to set * @return A modified copy of {@code this} object */ public final Models.Annotation withValues(Iterable elements) { if (this.values == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new Models.Annotation(this.declaringType, this.type, newValue); } /** * This instance is equal to all instances of {@code Annotation} 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 Models.Annotation && equalTo(0, (Models.Annotation) another); } private boolean equalTo(int synthetic, Models.Annotation another) { return Objects.equals(declaringType, another.declaringType) && type.equals(another.type) && values.equals(another.values); } /** * Computes a hash code from attributes: {@code declaringType}, {@code type}, {@code values}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(declaringType); h += (h << 5) + type.hashCode(); h += (h << 5) + values.hashCode(); return h; } /** * Prints the immutable value {@code Annotation} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("Annotation{"); if (declaringType != null) { builder.append("declaringType=").append(declaringType); } if (builder.length() > 11) builder.append(", "); builder.append("type=").append(type); builder.append(", "); builder.append("values=").append(values); return builder.append("}").toString(); } /** * Construct a new immutable {@code Annotation} instance. * @param type The value for the {@code type} attribute * @return An immutable Annotation instance */ public static Models.Annotation of(Model.AnnotationType type) { return new Models.Annotation(type); } /** * Creates an immutable copy of a {@link Model.Annotation} 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 Annotation instance */ public static Models.Annotation copyOf(Model.Annotation instance) { if (instance instanceof Models.Annotation) { return (Models.Annotation) instance; } return Models.Annotation.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.Annotation Annotation}. *

     * Models.Annotation.builder()
     *    .declaringType(cn.zenliu.units.codegen.model.Model.Type) // optional {@link Model.Annotation#declaringType() declaringType}
     *    .type(cn.zenliu.units.codegen.model.Model.AnnotationType) // required {@link Model.Annotation#type() type}
     *    .addValues|addAllValues(cn.zenliu.units.codegen.model.Model.AnnotatedValue) // {@link Model.Annotation#values() values} elements
     *    .build();
     * 
* @return A new Annotation builder */ public static Models.Annotation.Builder builder() { return new Models.Annotation.Builder(); } /** * Builds instances of type {@link Models.Annotation Annotation}. * 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 = "Model.Annotation", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_TYPE = 0x1L; private long initBits = 0x1L; private @Nullable Model.Type declaringType; private @Nullable Model.AnnotationType type; private List values = new ArrayList(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.DeclaringType} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.DeclaringType instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.Annotation} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.Annotation instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.With.DeclaringType) { Model.With.DeclaringType instance = (Model.With.DeclaringType) object; if ((bits & 0x1L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x1L; } } if (object instanceof Model.Annotation) { Model.Annotation instance = (Model.Annotation) object; type(instance.type()); if ((bits & 0x1L) == 0) { Optional declaringTypeOptional = instance.declaringType(); if (declaringTypeOptional.isPresent()) { declaringType(declaringTypeOptional); } bits |= 0x1L; } addAllValues(instance.values()); } } /** * Initializes the optional value {@link Model.Annotation#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(@Nullable Model.Type declaringType) { this.declaringType = declaringType; return this; } /** * Initializes the optional value {@link Model.Annotation#declaringType() declaringType} to declaringType. * @param declaringType The value for declaringType * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder declaringType(Optional declaringType) { this.declaringType = declaringType.orElse(null); return this; } /** * Constructs and initializes the value for the {@link Model.Annotation#type() type} attribute. * @param modifier The value for {@code type.modifier} * @param name The value for {@code type.name} * @param pkg The value for {@code type.pkg} * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder type(int modifier, String name, Model.Pkg pkg) { return type(Models.AnnotationType.of(modifier, name, pkg)); } /** * Initializes the value for the {@link Model.Annotation#type() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder type(Model.AnnotationType type) { this.type = Models.AnnotationType.copyOf(type); initBits &= ~INIT_BIT_TYPE; return this; } /** * Adds one element to {@link Model.Annotation#values() values} list. * @param element A values element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addValues(Model.AnnotatedValue element) { element = Models.AnnotatedValue.copyOf(element); this.values.add(Objects.requireNonNull(element, "values element")); return this; } /** * Constructs and adds an element for the {@link Model.Annotation#values() values} list. * @param name The value for {@code values.name} * @param type The value for {@code values.type} * @return {@code this} builder for use in a chained invocation */ public final Builder addValues(String name, Model.Type type) { return addValues(Models.AnnotatedValue.of(name, type)); } /** * Adds elements to {@link Model.Annotation#values() values} list. * @param elements An array of values elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addValues(Model.AnnotatedValue... elements) { for (Model.AnnotatedValue element : elements) { element = Models.AnnotatedValue.copyOf(element); this.values.add(Objects.requireNonNull(element, "values element")); } return this; } /** * Sets or replaces all elements for {@link Model.Annotation#values() values} list. * @param elements An iterable of values elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder values(Iterable elements) { this.values.clear(); return addAllValues(elements); } /** * Adds elements to {@link Model.Annotation#values() values} list. * @param elements An iterable of values elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllValues(Iterable elements) { for (Model.AnnotatedValue element : elements) { element = Models.AnnotatedValue.copyOf(element); this.values.add(Objects.requireNonNull(element, "values element")); } return this; } /** * Builds a new {@link Models.Annotation Annotation}. * @return An immutable instance of Annotation * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.Annotation build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.Annotation( declaringType, Models.AnnotationType.copyOf(type), createUnmodifiableList(true, values)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_TYPE) != 0) attributes.add("type"); return "Cannot build Annotation, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.AnnotatedValue}. *

* Use the builder to create immutable instances: * {@code Models.AnnotatedValue.builder()}. * Use the static factory method to create immutable instances: * {@code Models.AnnotatedValue.of()}. */ @Generated(from = "Model.AnnotatedValue", generator = "Immutables") @Immutable @CheckReturnValue public static final class AnnotatedValue implements Model.AnnotatedValue { private final String name; private final Model.Type type; private final @Nullable Object value; private AnnotatedValue(String name, Model.Type type) { this.name = Objects.requireNonNull(name, "name"); this.type = Objects.requireNonNull(type, "type"); this.value = null; } private AnnotatedValue( String name, Model.Type type, @Nullable Object value) { this.name = name; this.type = type; this.value = value; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * @return The value of the {@code type} attribute */ @Override public Model.Type type() { return type; } /** * One of String, Primitives, Annotation and their array type. */ @Override public Optional value() { return Optional.ofNullable(value); } /** * Copy the current immutable object by setting a value for the {@link Model.AnnotatedValue#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.AnnotatedValue withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.AnnotatedValue(newValue, this.type, this.value); } /** * Copy the current immutable object by setting a value for the {@link Model.AnnotatedValue#type() type} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for type * @return A modified copy of the {@code this} object */ public final Models.AnnotatedValue withType(Model.Type value) { if (this.type == value) return this; Model.Type newValue = Objects.requireNonNull(value, "type"); return new Models.AnnotatedValue(this.name, newValue, this.value); } /** * Copy the current immutable object by setting a present value for the optional {@link Model.AnnotatedValue#value() value} attribute. * @param value The value for value, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Models.AnnotatedValue withValue(@Nullable Object value) { @Nullable Object newValue = value; if (this.value == newValue) return this; return new Models.AnnotatedValue(this.name, this.type, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link Model.AnnotatedValue#value() value} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for value * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Models.AnnotatedValue withValue(Optional optional) { @Nullable Object value = optional.orElse(null); if (this.value == value) return this; return new Models.AnnotatedValue(this.name, this.type, value); } /** * This instance is equal to all instances of {@code AnnotatedValue} 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 Models.AnnotatedValue && equalTo(0, (Models.AnnotatedValue) another); } private boolean equalTo(int synthetic, Models.AnnotatedValue another) { return name.equals(another.name) && type.equals(another.type) && Objects.equals(value, another.value); } /** * Computes a hash code from attributes: {@code name}, {@code type}, {@code value}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + type.hashCode(); h += (h << 5) + Objects.hashCode(value); return h; } /** * Prints the immutable value {@code AnnotatedValue} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("AnnotatedValue{"); builder.append("name=").append(name); builder.append(", "); builder.append("type=").append(type); if (value != null) { builder.append(", "); builder.append("value=").append(value); } return builder.append("}").toString(); } /** * Construct a new immutable {@code AnnotatedValue} instance. * @param name The value for the {@code name} attribute * @param type The value for the {@code type} attribute * @return An immutable AnnotatedValue instance */ public static Models.AnnotatedValue of(String name, Model.Type type) { return new Models.AnnotatedValue(name, type); } /** * Creates an immutable copy of a {@link Model.AnnotatedValue} 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 AnnotatedValue instance */ public static Models.AnnotatedValue copyOf(Model.AnnotatedValue instance) { if (instance instanceof Models.AnnotatedValue) { return (Models.AnnotatedValue) instance; } return Models.AnnotatedValue.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.AnnotatedValue AnnotatedValue}. *
     * Models.AnnotatedValue.builder()
     *    .name(String) // required {@link Model.AnnotatedValue#name() name}
     *    .type(cn.zenliu.units.codegen.model.Model.Type) // required {@link Model.AnnotatedValue#type() type}
     *    .value(Object) // optional {@link Model.AnnotatedValue#value() value}
     *    .build();
     * 
* @return A new AnnotatedValue builder */ public static Models.AnnotatedValue.Builder builder() { return new Models.AnnotatedValue.Builder(); } /** * Builds instances of type {@link Models.AnnotatedValue AnnotatedValue}. * 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 = "Model.AnnotatedValue", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_NAME = 0x1L; private static final long INIT_BIT_TYPE = 0x2L; private long initBits = 0x3L; private @Nullable String name; private @Nullable Model.Type type; private @Nullable Object value; private Builder() { } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.AnnotatedValue} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.AnnotatedValue instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code cn.zenliu.units.codegen.model.Model.With.Name} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Model.With.Name instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { @Var long bits = 0; if (object instanceof Model.AnnotatedValue) { Model.AnnotatedValue instance = (Model.AnnotatedValue) object; type(instance.type()); if ((bits & 0x1L) == 0) { name(instance.name()); bits |= 0x1L; } Optional valueOptional = instance.value(); if (valueOptional.isPresent()) { value(valueOptional); } } if (object instanceof Model.With.Name) { Model.With.Name instance = (Model.With.Name) object; if ((bits & 0x1L) == 0) { name(instance.name()); bits |= 0x1L; } } } /** * Initializes the value for the {@link Model.AnnotatedValue#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Initializes the value for the {@link Model.AnnotatedValue#type() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder type(Model.Type type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return this; } /** * Initializes the optional value {@link Model.AnnotatedValue#value() value} to value. * @param value The value for value, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder value(@Nullable Object value) { this.value = value; return this; } /** * Initializes the optional value {@link Model.AnnotatedValue#value() value} to value. * @param value The value for value * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder value(Optional value) { this.value = value.orElse(null); return this; } /** * Builds a new {@link Models.AnnotatedValue AnnotatedValue}. * @return An immutable instance of AnnotatedValue * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.AnnotatedValue build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.AnnotatedValue(name, type, value); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_TYPE) != 0) attributes.add("type"); return "Cannot build AnnotatedValue, some of required attributes are not set " + attributes; } } } /** * Immutable implementation of {@link Model.Enum}. *

* Use the builder to create immutable instances: * {@code Models.Enum.builder()}. * Use the static factory method to create immutable instances: * {@code Models.Enum.of()}. */ @Generated(from = "Model.Enum", generator = "Immutables") @Immutable @CheckReturnValue public static final class Enum implements Model.Enum { private final Model.Type type; private final String name; private Enum(Model.Type type, String name) { this.type = Objects.requireNonNull(type, "type"); this.name = Objects.requireNonNull(name, "name"); } private Enum(Models.Enum original, Model.Type type, String name) { this.type = type; this.name = name; } /** * @return The value of the {@code type} attribute */ @Override public Model.Type type() { return type; } /** * @return The value of the {@code name} attribute */ @Override public String name() { return name; } /** * Copy the current immutable object by setting a value for the {@link Model.Enum#type() type} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for type * @return A modified copy of the {@code this} object */ public final Models.Enum withType(Model.Type value) { if (this.type == value) return this; Model.Type newValue = Objects.requireNonNull(value, "type"); return new Models.Enum(this, newValue, this.name); } /** * Copy the current immutable object by setting a value for the {@link Model.Enum#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final Models.Enum withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (this.name.equals(newValue)) return this; return new Models.Enum(this, this.type, newValue); } /** * This instance is equal to all instances of {@code Enum} 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 Models.Enum && equalTo(0, (Models.Enum) another); } private boolean equalTo(int synthetic, Models.Enum another) { return type.equals(another.type) && name.equals(another.name); } /** * Computes a hash code from attributes: {@code type}, {@code name}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + type.hashCode(); h += (h << 5) + name.hashCode(); return h; } /** * Prints the immutable value {@code Enum} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "Enum{" + "type=" + type + ", name=" + name + "}"; } /** * Construct a new immutable {@code Enum} instance. * @param type The value for the {@code type} attribute * @param name The value for the {@code name} attribute * @return An immutable Enum instance */ public static Models.Enum of(Model.Type type, String name) { return new Models.Enum(type, name); } /** * Creates an immutable copy of a {@link Model.Enum} 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 Enum instance */ public static Models.Enum copyOf(Model.Enum instance) { if (instance instanceof Models.Enum) { return (Models.Enum) instance; } return Models.Enum.builder() .from(instance) .build(); } /** * Creates a builder for {@link Models.Enum Enum}. *

     * Models.Enum.builder()
     *    .type(cn.zenliu.units.codegen.model.Model.Type) // required {@link Model.Enum#type() type}
     *    .name(String) // required {@link Model.Enum#name() name}
     *    .build();
     * 
* @return A new Enum builder */ public static Models.Enum.Builder builder() { return new Models.Enum.Builder(); } /** * Builds instances of type {@link Models.Enum Enum}. * 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 = "Model.Enum", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_TYPE = 0x1L; private static final long INIT_BIT_NAME = 0x2L; private long initBits = 0x3L; private @Nullable Model.Type type; private @Nullable String name; private Builder() { } /** * Fill a builder with attribute values from the provided {@code Enum} 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 */ @CanIgnoreReturnValue public final Builder from(Model.Enum instance) { Objects.requireNonNull(instance, "instance"); type(instance.type()); name(instance.name()); return this; } /** * Initializes the value for the {@link Model.Enum#type() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder type(Model.Type type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return this; } /** * Initializes the value for the {@link Model.Enum#name() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Builds a new {@link Models.Enum Enum}. * @return An immutable instance of Enum * @throws java.lang.IllegalStateException if any required attributes are missing */ public Models.Enum build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new Models.Enum(null, type, name); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_TYPE) != 0) attributes.add("type"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build Enum, some of required attributes are not set " + attributes; } } } private static List createSafeList(Iterable iterable, boolean checkNulls, boolean skipNulls) { ArrayList list; if (iterable instanceof Collection) { int size = ((Collection) iterable).size(); if (size == 0) return Collections.emptyList(); list = new ArrayList<>(size); } else { list = new ArrayList<>(); } for (T element : iterable) { if (skipNulls && element == null) continue; if (checkNulls) Objects.requireNonNull(element, "element"); list.add(element); } return list; } private static List createUnmodifiableList(boolean clone, List list) { switch(list.size()) { case 0: return Collections.emptyList(); case 1: return Collections.singletonList(list.get(0)); default: if (clone) { return Collections.unmodifiableList(new ArrayList<>(list)); } else { if (list instanceof ArrayList) { ((ArrayList) list).trimToSize(); } return Collections.unmodifiableList(list); } } } }