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

com.orbitz.consul.model.acl.ImmutablePolicyLink Maven / Gradle / Ivy

The newest version!
package com.orbitz.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 java.util.Objects;
import java.util.Optional;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link Token.PolicyLink}.
 * 

* Use the builder to create immutable instances: * {@code ImmutablePolicyLink.builder()}. */ @Generated(from = "Token.PolicyLink", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutablePolicyLink extends Token.PolicyLink { private final @Nullable String id; private final @Nullable String name; private ImmutablePolicyLink(@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.PolicyLink#id() id} attribute. * @param value The value for id * @return A modified copy of {@code this} object */ public final ImmutablePolicyLink withId(String value) { @Nullable String newValue = Objects.requireNonNull(value, "id"); if (Objects.equals(this.id, newValue)) return this; return new ImmutablePolicyLink(newValue, this.name); } /** * Copy the current immutable object by setting an optional value for the {@link Token.PolicyLink#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 ImmutablePolicyLink withId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.id, value)) return this; return new ImmutablePolicyLink(value, this.name); } /** * Copy the current immutable object by setting a present value for the optional {@link Token.PolicyLink#name() name} attribute. * @param value The value for name * @return A modified copy of {@code this} object */ public final ImmutablePolicyLink withName(String value) { @Nullable String newValue = Objects.requireNonNull(value, "name"); if (Objects.equals(this.name, newValue)) return this; return new ImmutablePolicyLink(this.id, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link Token.PolicyLink#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 ImmutablePolicyLink withName(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.name, value)) return this; return new ImmutablePolicyLink(this.id, value); } /** * This instance is equal to all instances of {@code ImmutablePolicyLink} 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 ImmutablePolicyLink && equalTo((ImmutablePolicyLink) another); } private boolean equalTo(ImmutablePolicyLink 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 PolicyLink} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("PolicyLink") .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.PolicyLink", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json extends Token.PolicyLink { @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 ImmutablePolicyLink fromJson(Json json) { ImmutablePolicyLink.Builder builder = ImmutablePolicyLink.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.PolicyLink} 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 PolicyLink instance */ public static ImmutablePolicyLink copyOf(Token.PolicyLink instance) { if (instance instanceof ImmutablePolicyLink) { return (ImmutablePolicyLink) instance; } return ImmutablePolicyLink.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutablePolicyLink ImmutablePolicyLink}. *

   * ImmutablePolicyLink.builder()
   *    .id(String) // optional {@link Token.PolicyLink#id() id}
   *    .name(String) // optional {@link Token.PolicyLink#name() name}
   *    .build();
   * 
* @return A new ImmutablePolicyLink builder */ public static ImmutablePolicyLink.Builder builder() { return new ImmutablePolicyLink.Builder(); } /** * Builds instances of type {@link ImmutablePolicyLink ImmutablePolicyLink}. * 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.PolicyLink", generator = "Immutables") @NotThreadSafe 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 PolicyLink} 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.PolicyLink 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.PolicyLink#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.PolicyLink#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.PolicyLink#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.PolicyLink#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 ImmutablePolicyLink ImmutablePolicyLink}. * @return An immutable instance of PolicyLink * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutablePolicyLink build() { return new ImmutablePolicyLink(id, name); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy