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

org.kiwiproject.consul.model.acl.ImmutableAclToken Maven / Gradle / Ivy

package org.kiwiproject.consul.model.acl;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import jakarta.annotation.Nullable;
import java.util.Objects;
import java.util.Optional;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableAclToken.builder()}. */ @Generated(from = "AclToken", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @JsonIgnoreProperties(ignoreUnknown = true) public final class ImmutableAclToken extends AclToken { private final @Nullable String id; private final @Nullable String name; private final @Nullable String type; private final @Nullable String rules; private ImmutableAclToken( @Nullable String id, @Nullable String name, @Nullable String type, @Nullable String rules) { this.id = id; this.name = name; this.type = type; this.rules = rules; } /** * @return The value of the {@code id} attribute */ @JsonProperty("ID") @Override public Optional id() { return Optional.ofNullable(id); } /** * @return The value of the {@code name} attribute */ @JsonProperty("Name") @Override public Optional name() { return Optional.ofNullable(name); } /** * @return The value of the {@code type} attribute */ @JsonProperty("Type") @Override public Optional type() { return Optional.ofNullable(type); } /** * @return The value of the {@code rules} attribute */ @JsonProperty("Rules") @Override public Optional rules() { return Optional.ofNullable(rules); } /** * Copy the current immutable object by setting a present value for the optional {@link AclToken#id() id} attribute. * @param value The value for id * @return A modified copy of {@code this} object */ public final ImmutableAclToken withId(String value) { String newValue = Objects.requireNonNull(value, "id"); if (Objects.equals(this.id, newValue)) return this; return new ImmutableAclToken(newValue, this.name, this.type, this.rules); } /** * Copy the current immutable object by setting an optional value for the {@link AclToken#id() id} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for id * @return A modified copy of {@code this} object */ public final ImmutableAclToken withId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.id, value)) return this; return new ImmutableAclToken(value, this.name, this.type, this.rules); } /** * Copy the current immutable object by setting a present value for the optional {@link AclToken#name() name} attribute. * @param value The value for name * @return A modified copy of {@code this} object */ public final ImmutableAclToken withName(String value) { String newValue = Objects.requireNonNull(value, "name"); if (Objects.equals(this.name, newValue)) return this; return new ImmutableAclToken(this.id, newValue, this.type, this.rules); } /** * Copy the current immutable object by setting an optional value for the {@link AclToken#name() name} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for name * @return A modified copy of {@code this} object */ public final ImmutableAclToken withName(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.name, value)) return this; return new ImmutableAclToken(this.id, value, this.type, this.rules); } /** * Copy the current immutable object by setting a present value for the optional {@link AclToken#type() type} attribute. * @param value The value for type * @return A modified copy of {@code this} object */ public final ImmutableAclToken withType(String value) { String newValue = Objects.requireNonNull(value, "type"); if (Objects.equals(this.type, newValue)) return this; return new ImmutableAclToken(this.id, this.name, newValue, this.rules); } /** * Copy the current immutable object by setting an optional value for the {@link AclToken#type() type} attribute. * An equality check is used on inner nullable 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 */ public final ImmutableAclToken withType(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.type, value)) return this; return new ImmutableAclToken(this.id, this.name, value, this.rules); } /** * Copy the current immutable object by setting a present value for the optional {@link AclToken#rules() rules} attribute. * @param value The value for rules * @return A modified copy of {@code this} object */ public final ImmutableAclToken withRules(String value) { String newValue = Objects.requireNonNull(value, "rules"); if (Objects.equals(this.rules, newValue)) return this; return new ImmutableAclToken(this.id, this.name, this.type, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link AclToken#rules() rules} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for rules * @return A modified copy of {@code this} object */ public final ImmutableAclToken withRules(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.rules, value)) return this; return new ImmutableAclToken(this.id, this.name, this.type, value); } /** * This instance is equal to all instances of {@code ImmutableAclToken} 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 ImmutableAclToken && equalTo(0, (ImmutableAclToken) another); } private boolean equalTo(int synthetic, ImmutableAclToken another) { return Objects.equals(id, another.id) && Objects.equals(name, another.name) && Objects.equals(type, another.type) && Objects.equals(rules, another.rules); } /** * Computes a hash code from attributes: {@code id}, {@code name}, {@code type}, {@code rules}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(id); h += (h << 5) + Objects.hashCode(name); h += (h << 5) + Objects.hashCode(type); h += (h << 5) + Objects.hashCode(rules); return h; } /** * Prints the immutable value {@code AclToken} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("AclToken") .omitNullValues() .add("id", id) .add("name", name) .add("type", type) .add("rules", rules) .toString(); } /** * 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 = "AclToken", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json extends AclToken { @Nullable Optional id = Optional.empty(); @Nullable Optional name = Optional.empty(); @Nullable Optional type = Optional.empty(); @Nullable Optional rules = Optional.empty(); @JsonProperty("ID") public void setId(Optional id) { this.id = id; } @JsonProperty("Name") public void setName(Optional name) { this.name = name; } @JsonProperty("Type") public void setType(Optional type) { this.type = type; } @JsonProperty("Rules") public void setRules(Optional rules) { this.rules = rules; } @Override public Optional id() { throw new UnsupportedOperationException(); } @Override public Optional name() { throw new UnsupportedOperationException(); } @Override public Optional type() { throw new UnsupportedOperationException(); } @Override public Optional rules() { 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 ImmutableAclToken fromJson(Json json) { ImmutableAclToken.Builder builder = ImmutableAclToken.builder(); if (json.id != null) { builder.id(json.id); } if (json.name != null) { builder.name(json.name); } if (json.type != null) { builder.type(json.type); } if (json.rules != null) { builder.rules(json.rules); } return builder.build(); } /** * Creates an immutable copy of a {@link AclToken} 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 AclToken instance */ public static ImmutableAclToken copyOf(AclToken instance) { if (instance instanceof ImmutableAclToken) { return (ImmutableAclToken) instance; } return ImmutableAclToken.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableAclToken ImmutableAclToken}. *

   * ImmutableAclToken.builder()
   *    .id(String) // optional {@link AclToken#id() id}
   *    .name(String) // optional {@link AclToken#name() name}
   *    .type(String) // optional {@link AclToken#type() type}
   *    .rules(String) // optional {@link AclToken#rules() rules}
   *    .build();
   * 
* @return A new ImmutableAclToken builder */ public static ImmutableAclToken.Builder builder() { return new ImmutableAclToken.Builder(); } /** * Builds instances of type {@link ImmutableAclToken ImmutableAclToken}. * 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 = "AclToken", generator = "Immutables") public static final class Builder { private @Nullable String id; private @Nullable String name; private @Nullable String type; private @Nullable String rules; private Builder() { } /** * Fill a builder with attribute values from the provided {@code AclToken} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(AclToken instance) { Objects.requireNonNull(instance, "instance"); Optional idOptional = instance.id(); if (idOptional.isPresent()) { id(idOptional); } Optional nameOptional = instance.name(); if (nameOptional.isPresent()) { name(nameOptional); } Optional typeOptional = instance.type(); if (typeOptional.isPresent()) { type(typeOptional); } Optional rulesOptional = instance.rules(); if (rulesOptional.isPresent()) { rules(rulesOptional); } return this; } /** * Initializes the optional value {@link AclToken#id() id} to id. * @param id The value for id * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder id(String id) { this.id = Objects.requireNonNull(id, "id"); return this; } /** * Initializes the optional value {@link AclToken#id() id} to id. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("ID") public final Builder id(Optional id) { this.id = id.orElse(null); return this; } /** * Initializes the optional value {@link AclToken#name() name} to name. * @param name The value for name * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); return this; } /** * Initializes the optional value {@link AclToken#name() name} to name. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("Name") public final Builder name(Optional name) { this.name = name.orElse(null); return this; } /** * Initializes the optional value {@link AclToken#type() type} to type. * @param type The value for type * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder type(String type) { this.type = Objects.requireNonNull(type, "type"); return this; } /** * Initializes the optional value {@link AclToken#type() type} to type. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("Type") public final Builder type(Optional type) { this.type = type.orElse(null); return this; } /** * Initializes the optional value {@link AclToken#rules() rules} to rules. * @param rules The value for rules * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder rules(String rules) { this.rules = Objects.requireNonNull(rules, "rules"); return this; } /** * Initializes the optional value {@link AclToken#rules() rules} to rules. * @param rules The value for rules * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("Rules") public final Builder rules(Optional rules) { this.rules = rules.orElse(null); return this; } /** * Builds a new {@link ImmutableAclToken ImmutableAclToken}. * @return An immutable instance of AclToken * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableAclToken build() { return new ImmutableAclToken(id, name, type, rules); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy