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

dz.jtsgen.processor.dsl.model.TSMappedTerminalBuilder Maven / Gradle / Ivy

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

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

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

* Use the builder to create immutable instances: * {@code TSMappedTerminalBuilder.builder()}. * Use the static factory method to create immutable instances: * {@code TSMappedTerminalBuilder.of()}. */ @SuppressWarnings({"all"}) @Generated({"Immutables.generator", "TSMappedTerminal"}) public final class TSMappedTerminalBuilder extends TSMappedTerminal { private final String value; private TSMappedTerminalBuilder(String value) { this.value = Objects.requireNonNull(value, "value"); } private TSMappedTerminalBuilder(TSMappedTerminalBuilder original, String value) { this.value = value; } /** * @return The value of the {@code value} attribute */ @Override public String value() { return value; } /** * Copy the current immutable object by setting a value for the {@link TSMappedTerminal#value() value} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for value * @return A modified copy of the {@code this} object */ public final TSMappedTerminalBuilder withValue(String value) { if (this.value.equals(value)) return this; String newValue = Objects.requireNonNull(value, "value"); return new TSMappedTerminalBuilder(this, newValue); } /** * This instance is equal to all instances of {@code TSMappedTerminalBuilder} 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 TSMappedTerminalBuilder && equalTo((TSMappedTerminalBuilder) another); } private boolean equalTo(TSMappedTerminalBuilder another) { return value.equals(another.value); } /** * Computes a hash code from attributes: {@code value}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + value.hashCode(); return h; } /** * Prints the immutable value {@code TSMappedTerminal} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "TSMappedTerminal{" + "value=" + value + "}"; } /** * Construct a new immutable {@code TSMappedTerminal} instance. * @param value The value for the {@code value} attribute * @return An immutable TSMappedTerminal instance */ public static TSMappedTerminalBuilder of(String value) { return new TSMappedTerminalBuilder(value); } /** * Creates an immutable copy of a {@link TSMappedTerminal} 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 TSMappedTerminal instance */ public static TSMappedTerminalBuilder copyOf(TSMappedTerminal instance) { if (instance instanceof TSMappedTerminalBuilder) { return (TSMappedTerminalBuilder) instance; } return TSMappedTerminalBuilder.builder() .from(instance) .build(); } /** * Creates a builder for {@link TSMappedTerminalBuilder TSMappedTerminalBuilder}. * @return A new TSMappedTerminalBuilder builder */ public static TSMappedTerminalBuilder.Builder builder() { return new TSMappedTerminalBuilder.Builder(); } /** * Builds instances of type {@link TSMappedTerminalBuilder TSMappedTerminalBuilder}. * 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_VALUE = 0x1L; private long initBits = 0x1L; private String value; private Builder() { } /** * Fill a builder with attribute values from the provided {@code dz.jtsgen.processor.dsl.model.TSExpressionElement} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(TSExpressionElement instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code dz.jtsgen.processor.dsl.model.TSMappedTerminal} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(TSMappedTerminal instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { if (object instanceof TSExpressionElement) { TSExpressionElement instance = (TSExpressionElement) object; value(instance.value()); } } /** * Initializes the value for the {@link TSMappedTerminal#value() value} attribute. * @param value The value for value * @return {@code this} builder for use in a chained invocation */ public final Builder value(String value) { this.value = Objects.requireNonNull(value, "value"); initBits &= ~INIT_BIT_VALUE; return this; } /** * Builds a new {@link TSMappedTerminalBuilder TSMappedTerminalBuilder}. * @return An immutable instance of TSMappedTerminal * @throws java.lang.IllegalStateException if any required attributes are missing */ public TSMappedTerminalBuilder build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new TSMappedTerminalBuilder(null, value); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList(); if ((initBits & INIT_BIT_VALUE) != 0) attributes.add("value"); return "Cannot build TSMappedTerminal, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy