cn.zenliu.units.codegen.model.Models Maven / Gradle / Ivy
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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Field> 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 extends Model.Method> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Field> 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 extends Model.Field> 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 extends Model.Method> 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 extends Model.Method> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Field> 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 extends Model.Method> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Field> 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 extends Model.Field> 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 extends Model.Method> 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 extends Model.Method> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Field> 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 extends Model.Method> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Field> 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 extends Model.Field> 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 extends Model.Method> 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 extends Model.Method> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Method> 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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Type> 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 extends Model.Method> 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 extends Model.Method> 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 extends Model.Annotation> 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 extends Model.TypeVar> 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 extends Model.Type> 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 extends Model.Parameter> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.TypeVar> 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 extends Model.TypeVar> 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 extends Model.Type> 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 extends Model.Parameter> 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 extends Model.Parameter> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Annotation> 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 extends Model.Type> 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 extends Model.Annotation> 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 extends Model.Type> 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