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

org.kiwiproject.consul.model.acl.ImmutableRoleLink 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.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 Token.RoleLink}.
 * 

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

   * ImmutableRoleLink.builder()
   *    .id(String) // optional {@link Token.RoleLink#id() id}
   *    .name(String) // optional {@link Token.RoleLink#name() name}
   *    .build();
   * 
* @return A new ImmutableRoleLink builder */ public static ImmutableRoleLink.Builder builder() { return new ImmutableRoleLink.Builder(); } /** * Builds instances of type {@link ImmutableRoleLink ImmutableRoleLink}. * 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 = "Token.RoleLink", generator = "Immutables") public static final class Builder { private @Nullable String id; private @Nullable String name; private Builder() { } /** * Fill a builder with attribute values from the provided {@code RoleLink} 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(Token.RoleLink instance) { Objects.requireNonNull(instance, "instance"); Optional idOptional = instance.id(); if (idOptional.isPresent()) { id(idOptional); } Optional nameOptional = instance.name(); if (nameOptional.isPresent()) { name(nameOptional); } return this; } /** * Initializes the optional value {@link Token.RoleLink#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 Token.RoleLink#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 Token.RoleLink#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 Token.RoleLink#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; } /** * Builds a new {@link ImmutableRoleLink ImmutableRoleLink}. * @return An immutable instance of RoleLink * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableRoleLink build() { return new ImmutableRoleLink(id, name); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy