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

dz.jtsgen.processor.model.TSRegularMemberBuilder Maven / Gradle / Ivy

There is a newer version: 0.5.0
Show newest version
package dz.jtsgen.processor.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.Generated;

/**
 * Immutable implementation of {@link TSRegularMember}.
 * 

* Use the builder to create immutable instances: * {@code TSRegularMemberBuilder.builder()}. * Use the static factory method to create immutable instances: * {@code TSRegularMemberBuilder.of()}. */ @SuppressWarnings({"all"}) @Generated({"Immutables.generator", "TSRegularMember"}) public final class TSRegularMemberBuilder extends TSRegularMember { private final String name; private final TSTargetType type; private final boolean readOnly; private final boolean invalid; private TSRegularMemberBuilder(String name, TSTargetType type, boolean readOnly) { this.name = Objects.requireNonNull(name, "name"); this.type = Objects.requireNonNull(type, "type"); this.readOnly = readOnly; this.invalid = super.getInvalid(); } private TSRegularMemberBuilder(TSRegularMemberBuilder.Builder builder) { this.name = builder.name; this.type = builder.type; this.readOnly = builder.readOnly; this.invalid = builder.invalidIsSet() ? builder.invalid : super.getInvalid(); } private TSRegularMemberBuilder( String name, TSTargetType type, boolean readOnly, boolean invalid) { this.name = name; this.type = type; this.readOnly = readOnly; this.invalid = invalid; } /** * @return The value of the {@code name} attribute */ @Override public String getName() { return name; } /** * @return The value of the {@code type} attribute */ @Override public TSTargetType getType() { return type; } /** * @return The value of the {@code readOnly} attribute */ @Override public boolean getReadOnly() { return readOnly; } /** * @return The value of the {@code invalid} attribute */ @Override public boolean getInvalid() { return invalid; } /** * Copy the current immutable object by setting a value for the {@link TSRegularMember#getName() 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 TSRegularMemberBuilder withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new TSRegularMemberBuilder(newValue, this.type, this.readOnly, this.invalid); } /** * Copy the current immutable object by setting a value for the {@link TSRegularMember#getType() 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 TSRegularMemberBuilder withType(TSTargetType value) { if (this.type == value) return this; TSTargetType newValue = Objects.requireNonNull(value, "type"); return new TSRegularMemberBuilder(this.name, newValue, this.readOnly, this.invalid); } /** * Copy the current immutable object by setting a value for the {@link TSRegularMember#getReadOnly() readOnly} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for readOnly * @return A modified copy of the {@code this} object */ public final TSRegularMemberBuilder withReadOnly(boolean value) { if (this.readOnly == value) return this; return new TSRegularMemberBuilder(this.name, this.type, value, this.invalid); } /** * Copy the current immutable object by setting a value for the {@link TSRegularMember#getInvalid() invalid} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for invalid * @return A modified copy of the {@code this} object */ public final TSRegularMemberBuilder withInvalid(boolean value) { if (this.invalid == value) return this; return new TSRegularMemberBuilder(this.name, this.type, this.readOnly, value); } /** * This instance is equal to all instances of {@code TSRegularMemberBuilder} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof TSRegularMemberBuilder && equalTo((TSRegularMemberBuilder) another); } private boolean equalTo(TSRegularMemberBuilder another) { return name.equals(another.name) && type.equals(another.type) && readOnly == another.readOnly && invalid == another.invalid; } /** * Computes a hash code from attributes: {@code name}, {@code type}, {@code readOnly}, {@code invalid}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + name.hashCode(); h += (h << 5) + type.hashCode(); h += (h << 5) + Boolean.hashCode(readOnly); h += (h << 5) + Boolean.hashCode(invalid); return h; } /** * Prints the immutable value {@code TSRegularMember} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "TSRegularMember{" + "name=" + name + ", type=" + type + ", readOnly=" + readOnly + ", invalid=" + invalid + "}"; } /** * Construct a new immutable {@code TSRegularMember} instance. * @param name The value for the {@code name} attribute * @param type The value for the {@code type} attribute * @param readOnly The value for the {@code readOnly} attribute * @return An immutable TSRegularMember instance */ public static TSRegularMemberBuilder of(String name, TSTargetType type, boolean readOnly) { return new TSRegularMemberBuilder(name, type, readOnly); } /** * Creates an immutable copy of a {@link TSRegularMember} 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 TSRegularMember instance */ public static TSRegularMemberBuilder copyOf(TSRegularMember instance) { if (instance instanceof TSRegularMemberBuilder) { return (TSRegularMemberBuilder) instance; } return TSRegularMemberBuilder.builder() .from(instance) .build(); } /** * Creates a builder for {@link TSRegularMemberBuilder TSRegularMemberBuilder}. * @return A new TSRegularMemberBuilder builder */ public static TSRegularMemberBuilder.Builder builder() { return new TSRegularMemberBuilder.Builder(); } /** * Builds instances of type {@link TSRegularMemberBuilder TSRegularMemberBuilder}. * 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. */ public static final class Builder { private static final long INIT_BIT_NAME = 0x1L; private static final long INIT_BIT_TYPE = 0x2L; private static final long INIT_BIT_READ_ONLY = 0x4L; private static final long OPT_BIT_INVALID = 0x1L; private long initBits = 0x7L; private long optBits; private String name; private TSTargetType type; private boolean readOnly; private boolean invalid; private Builder() { } /** * Fill a builder with attribute values from the provided {@code dz.jtsgen.processor.model.TSRegularMember} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(TSRegularMember instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code dz.jtsgen.processor.model.TSMember} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(TSMember instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { long bits = 0; if (object instanceof TSRegularMember) { TSRegularMember instance = (TSRegularMember) object; if ((bits & 0x1L) == 0) { name(instance.getName()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { invalid(instance.getInvalid()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { readOnly(instance.getReadOnly()); bits |= 0x4L; } if ((bits & 0x8L) == 0) { type(instance.getType()); bits |= 0x8L; } } if (object instanceof TSMember) { TSMember instance = (TSMember) object; if ((bits & 0x1L) == 0) { name(instance.getName()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { invalid(instance.getInvalid()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { readOnly(instance.getReadOnly()); bits |= 0x4L; } if ((bits & 0x8L) == 0) { type(instance.getType()); bits |= 0x8L; } } } /** * Initializes the value for the {@link TSRegularMember#getName() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Initializes the value for the {@link TSRegularMember#getType() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ public final Builder type(TSTargetType type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return this; } /** * Initializes the value for the {@link TSRegularMember#getReadOnly() readOnly} attribute. * @param readOnly The value for readOnly * @return {@code this} builder for use in a chained invocation */ public final Builder readOnly(boolean readOnly) { this.readOnly = readOnly; initBits &= ~INIT_BIT_READ_ONLY; return this; } /** * Initializes the value for the {@link TSRegularMember#getInvalid() invalid} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link TSRegularMember#getInvalid() invalid}. * @param invalid The value for invalid * @return {@code this} builder for use in a chained invocation */ public final Builder invalid(boolean invalid) { this.invalid = invalid; optBits |= OPT_BIT_INVALID; return this; } /** * Builds a new {@link TSRegularMemberBuilder TSRegularMemberBuilder}. * @return An immutable instance of TSRegularMember * @throws java.lang.IllegalStateException if any required attributes are missing */ public TSRegularMemberBuilder build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new TSRegularMemberBuilder(this); } private boolean invalidIsSet() { return (optBits & OPT_BIT_INVALID) != 0; } private String formatRequiredAttributesMessage() { List attributes = new ArrayList(); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); if ((initBits & INIT_BIT_TYPE) != 0) attributes.add("type"); if ((initBits & INIT_BIT_READ_ONLY) != 0) attributes.add("readOnly"); return "Cannot build TSRegularMember, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy