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

wtf.metio.yosql.models.configuration.ImmutableAnnotationMember Maven / Gradle / Ivy

package wtf.metio.yosql.models.configuration;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableAnnotationMember.builder()}. */ @Generated(from = "AnnotationMember", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableAnnotationMember implements AnnotationMember { private final String key; private final String value; private final String type; private ImmutableAnnotationMember(ImmutableAnnotationMember.Builder builder) { this.key = builder.key; this.value = builder.value; this.type = builder.typeIsSet() ? builder.type : Objects.requireNonNull(AnnotationMember.super.type(), "type"); } private ImmutableAnnotationMember(String key, String value, String type) { this.key = key; this.value = value; this.type = type; } /** * @return The key or name of the annotation member. */ @JsonProperty("key") @Override public String key() { return key; } /** * @return The value of the annotation member. */ @JsonProperty("value") @Override public String value() { return value; } /** * @return The fully-qualified type of the annotation member. */ @JsonProperty("type") @Override public String type() { return type; } /** * Copy the current immutable object by setting a value for the {@link AnnotationMember#key() key} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for key * @return A modified copy of the {@code this} object */ public final ImmutableAnnotationMember withKey(String value) { String newValue = Objects.requireNonNull(value, "key"); if (this.key.equals(newValue)) return this; return new ImmutableAnnotationMember(newValue, this.value, this.type); } /** * Copy the current immutable object by setting a value for the {@link AnnotationMember#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 ImmutableAnnotationMember withValue(String value) { String newValue = Objects.requireNonNull(value, "value"); if (this.value.equals(newValue)) return this; return new ImmutableAnnotationMember(this.key, newValue, this.type); } /** * Copy the current immutable object by setting a value for the {@link AnnotationMember#type() type} attribute. * An equals check 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 ImmutableAnnotationMember withType(String value) { String newValue = Objects.requireNonNull(value, "type"); if (this.type.equals(newValue)) return this; return new ImmutableAnnotationMember(this.key, this.value, newValue); } /** * This instance is equal to all instances of {@code ImmutableAnnotationMember} 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 ImmutableAnnotationMember && equalTo(0, (ImmutableAnnotationMember) another); } private boolean equalTo(int synthetic, ImmutableAnnotationMember another) { return key.equals(another.key) && value.equals(another.value) && type.equals(another.type); } /** * Computes a hash code from attributes: {@code key}, {@code value}, {@code type}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + key.hashCode(); h += (h << 5) + value.hashCode(); h += (h << 5) + type.hashCode(); return h; } /** * Prints the immutable value {@code AnnotationMember} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "AnnotationMember{" + "key=" + key + ", value=" + value + ", type=" + type + "}"; } /** * Utility type used to correctly read immutable object from JSON representation. * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure */ @Generated(from = "AnnotationMember", generator = "Immutables") @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements AnnotationMember { String key; String value; String type; boolean typeIsSet; @JsonProperty("key") public void setKey(String key) { this.key = key; } @JsonProperty("value") public void setValue(String value) { this.value = value; } @JsonProperty("type") public void setType(String type) { this.type = type; this.typeIsSet = true; } @Override public String key() { throw new UnsupportedOperationException(); } @Override public String value() { throw new UnsupportedOperationException(); } @Override public String type() { throw new UnsupportedOperationException(); } } /** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonCreator(mode = JsonCreator.Mode.DELEGATING) static ImmutableAnnotationMember fromJson(Json json) { ImmutableAnnotationMember.Builder builder = ((ImmutableAnnotationMember.Builder) ImmutableAnnotationMember.builder()); if (json.key != null) { builder.setKey(json.key); } if (json.value != null) { builder.setValue(json.value); } if (json.typeIsSet) { builder.setType(json.type); } return builder.build(); } /** * Creates an immutable copy of a {@link AnnotationMember} 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 AnnotationMember instance */ public static ImmutableAnnotationMember copyOf(AnnotationMember instance) { if (instance instanceof ImmutableAnnotationMember) { return (ImmutableAnnotationMember) instance; } return ((ImmutableAnnotationMember.Builder) ImmutableAnnotationMember.builder()) .setKey(instance.key()) .setValue(instance.value()) .setType(instance.type()) .build(); } /** * Creates a builder for {@link ImmutableAnnotationMember ImmutableAnnotationMember}. *

   * ImmutableAnnotationMember.builder()
   *    .setKey(String) // required {@link AnnotationMember#key() key}
   *    .setValue(String) // required {@link AnnotationMember#value() value}
   *    .setType(String) // optional {@link AnnotationMember#type() type}
   *    .build();
   * 
* @return A new ImmutableAnnotationMember builder */ public static KeyBuildStage builder() { return new ImmutableAnnotationMember.Builder(); } /** * Builds instances of type {@link ImmutableAnnotationMember ImmutableAnnotationMember}. * 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 = "AnnotationMember", generator = "Immutables") public static final class Builder implements KeyBuildStage, ValueBuildStage, BuildFinal { private static final long INIT_BIT_KEY = 0x1L; private static final long INIT_BIT_VALUE = 0x2L; private static final long OPT_BIT_TYPE = 0x1L; private long initBits = 0x3L; private long optBits; private String key; private String value; private String type; private Builder() { } /** * Initializes the value for the {@link AnnotationMember#key() key} attribute. * @param key The value for key * @return {@code this} builder for use in a chained invocation */ @JsonProperty("key") public final Builder setKey(String key) { checkNotIsSet(keyIsSet(), "key"); this.key = Objects.requireNonNull(key, "key"); initBits &= ~INIT_BIT_KEY; return this; } /** * Initializes the value for the {@link AnnotationMember#value() value} attribute. * @param value The value for value * @return {@code this} builder for use in a chained invocation */ @JsonProperty("value") public final Builder setValue(String value) { checkNotIsSet(valueIsSet(), "value"); this.value = Objects.requireNonNull(value, "value"); initBits &= ~INIT_BIT_VALUE; return this; } /** * Initializes the value for the {@link AnnotationMember#type() type} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link AnnotationMember#type() type}. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @JsonProperty("type") public final Builder setType(String type) { checkNotIsSet(typeIsSet(), "type"); this.type = Objects.requireNonNull(type, "type"); optBits |= OPT_BIT_TYPE; return this; } /** * Builds a new {@link ImmutableAnnotationMember ImmutableAnnotationMember}. * @return An immutable instance of AnnotationMember * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableAnnotationMember build() { checkRequiredAttributes(); return new ImmutableAnnotationMember(this); } private boolean typeIsSet() { return (optBits & OPT_BIT_TYPE) != 0; } private boolean keyIsSet() { return (initBits & INIT_BIT_KEY) == 0; } private boolean valueIsSet() { return (initBits & INIT_BIT_VALUE) == 0; } private static void checkNotIsSet(boolean isSet, String name) { if (isSet) throw new IllegalStateException("Builder of AnnotationMember is strict, attribute is already set: ".concat(name)); } private void checkRequiredAttributes() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!keyIsSet()) attributes.add("key"); if (!valueIsSet()) attributes.add("value"); return "Cannot build AnnotationMember, some of required attributes are not set " + attributes; } } @Generated(from = "AnnotationMember", generator = "Immutables") public interface KeyBuildStage { /** * Initializes the value for the {@link AnnotationMember#key() key} attribute. * @param key The value for key * @return {@code this} builder for use in a chained invocation */ ValueBuildStage setKey(String key); } @Generated(from = "AnnotationMember", generator = "Immutables") public interface ValueBuildStage { /** * Initializes the value for the {@link AnnotationMember#value() value} attribute. * @param value The value for value * @return {@code this} builder for use in a chained invocation */ BuildFinal setValue(String value); } @Generated(from = "AnnotationMember", generator = "Immutables") public interface BuildFinal { /** * Initializes the value for the {@link AnnotationMember#type() type} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link AnnotationMember#type() type}. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ BuildFinal setType(String type); /** * Builds a new {@link ImmutableAnnotationMember ImmutableAnnotationMember}. * @return An immutable instance of AnnotationMember * @throws java.lang.IllegalStateException if any required attributes are missing */ ImmutableAnnotationMember build(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy