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

com.spotify.github.v3.issues.ImmutableLabel Maven / Gradle / Ivy

The newest version!
package com.spotify.github.v3.issues;

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.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
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 Label}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableLabel.builder()}. */ @Generated(from = "Label", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableLabel implements Label { private final Long id; private final @Nullable String nodeId; private final @Nullable URI url; private final @Nullable String name; private final @Nullable String color; private final @Nullable String description; private final boolean isDefault; private ImmutableLabel( Long id, @Nullable String nodeId, @Nullable URI url, @Nullable String name, @Nullable String color, @Nullable String description, boolean isDefault) { this.id = id; this.nodeId = nodeId; this.url = url; this.name = name; this.color = color; this.description = description; this.isDefault = isDefault; } /** * Id */ @JsonProperty @Override public Long id() { return id; } /** * @return The value of the {@code nodeId} attribute */ @JsonProperty @Override public @Nullable String nodeId() { return nodeId; } /** * URL */ @JsonProperty @Override public @Nullable URI url() { return url; } /** * Name */ @JsonProperty @Override public @Nullable String name() { return name; } /** * Color */ @JsonProperty @Override public @Nullable String color() { return color; } /** * @return The value of the {@code description} attribute */ @JsonProperty @Override public @Nullable String description() { return description; } /** * Default */ @JsonProperty("default") @Override public boolean isDefault() { return isDefault; } /** * Copy the current immutable object by setting a value for the {@link Label#id() id} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for id * @return A modified copy of the {@code this} object */ public final ImmutableLabel withId(Long value) { Long newValue = Objects.requireNonNull(value, "id"); if (this.id.equals(newValue)) return this; return new ImmutableLabel(newValue, this.nodeId, this.url, this.name, this.color, this.description, this.isDefault); } /** * Copy the current immutable object by setting a value for the {@link Label#nodeId() nodeId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for nodeId (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableLabel withNodeId(@Nullable String value) { if (Objects.equals(this.nodeId, value)) return this; return new ImmutableLabel(this.id, value, this.url, this.name, this.color, this.description, this.isDefault); } /** * Copy the current immutable object by setting a value for the {@link Label#url() url} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for url (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableLabel withUrl(@Nullable URI value) { if (this.url == value) return this; return new ImmutableLabel(this.id, this.nodeId, value, this.name, this.color, this.description, this.isDefault); } /** * Copy the current immutable object by setting a value for the {@link Label#name() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableLabel withName(@Nullable String value) { if (Objects.equals(this.name, value)) return this; return new ImmutableLabel(this.id, this.nodeId, this.url, value, this.color, this.description, this.isDefault); } /** * Copy the current immutable object by setting a value for the {@link Label#color() color} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for color (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableLabel withColor(@Nullable String value) { if (Objects.equals(this.color, value)) return this; return new ImmutableLabel(this.id, this.nodeId, this.url, this.name, value, this.description, this.isDefault); } /** * Copy the current immutable object by setting a value for the {@link Label#description() description} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for description (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableLabel withDescription(@Nullable String value) { if (Objects.equals(this.description, value)) return this; return new ImmutableLabel(this.id, this.nodeId, this.url, this.name, this.color, value, this.isDefault); } /** * Copy the current immutable object by setting a value for the {@link Label#isDefault() isDefault} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for isDefault * @return A modified copy of the {@code this} object */ public final ImmutableLabel withIsDefault(boolean value) { if (this.isDefault == value) return this; return new ImmutableLabel(this.id, this.nodeId, this.url, this.name, this.color, this.description, value); } /** * This instance is equal to all instances of {@code ImmutableLabel} 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 ImmutableLabel && equalTo(0, (ImmutableLabel) another); } private boolean equalTo(int synthetic, ImmutableLabel another) { return id.equals(another.id) && Objects.equals(nodeId, another.nodeId) && Objects.equals(url, another.url) && Objects.equals(name, another.name) && Objects.equals(color, another.color) && Objects.equals(description, another.description) && isDefault == another.isDefault; } /** * Computes a hash code from attributes: {@code id}, {@code nodeId}, {@code url}, {@code name}, {@code color}, {@code description}, {@code isDefault}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + id.hashCode(); h += (h << 5) + Objects.hashCode(nodeId); h += (h << 5) + Objects.hashCode(url); h += (h << 5) + Objects.hashCode(name); h += (h << 5) + Objects.hashCode(color); h += (h << 5) + Objects.hashCode(description); h += (h << 5) + Boolean.hashCode(isDefault); return h; } /** * Prints the immutable value {@code Label} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "Label{" + "id=" + id + ", nodeId=" + nodeId + ", url=" + url + ", name=" + name + ", color=" + color + ", description=" + description + ", isDefault=" + isDefault + "}"; } /** * 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 = "Label", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements Label { @Nullable Long id; @Nullable String nodeId; @Nullable URI url; @Nullable String name; @Nullable String color; @Nullable String description; boolean isDefault; boolean isDefaultIsSet; @JsonProperty public void setId(Long id) { this.id = id; } @JsonProperty public void setNodeId(@Nullable String nodeId) { this.nodeId = nodeId; } @JsonProperty public void setUrl(@Nullable URI url) { this.url = url; } @JsonProperty public void setName(@Nullable String name) { this.name = name; } @JsonProperty public void setColor(@Nullable String color) { this.color = color; } @JsonProperty public void setDescription(@Nullable String description) { this.description = description; } @JsonProperty("default") public void setIsDefault(boolean isDefault) { this.isDefault = isDefault; this.isDefaultIsSet = true; } @Override public Long id() { throw new UnsupportedOperationException(); } @Override public String nodeId() { throw new UnsupportedOperationException(); } @Override public URI url() { throw new UnsupportedOperationException(); } @Override public String name() { throw new UnsupportedOperationException(); } @Override public String color() { throw new UnsupportedOperationException(); } @Override public String description() { throw new UnsupportedOperationException(); } @Override public boolean isDefault() { 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 ImmutableLabel fromJson(Json json) { ImmutableLabel.Builder builder = ImmutableLabel.builder(); if (json.id != null) { builder.id(json.id); } if (json.nodeId != null) { builder.nodeId(json.nodeId); } if (json.url != null) { builder.url(json.url); } if (json.name != null) { builder.name(json.name); } if (json.color != null) { builder.color(json.color); } if (json.description != null) { builder.description(json.description); } if (json.isDefaultIsSet) { builder.isDefault(json.isDefault); } return builder.build(); } /** * Creates an immutable copy of a {@link Label} 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 Label instance */ public static ImmutableLabel copyOf(Label instance) { if (instance instanceof ImmutableLabel) { return (ImmutableLabel) instance; } return ImmutableLabel.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableLabel ImmutableLabel}. *

   * ImmutableLabel.builder()
   *    .id(Long) // required {@link Label#id() id}
   *    .nodeId(String | null) // nullable {@link Label#nodeId() nodeId}
   *    .url(java.net.URI | null) // nullable {@link Label#url() url}
   *    .name(String | null) // nullable {@link Label#name() name}
   *    .color(String | null) // nullable {@link Label#color() color}
   *    .description(String | null) // nullable {@link Label#description() description}
   *    .isDefault(boolean) // required {@link Label#isDefault() isDefault}
   *    .build();
   * 
* @return A new ImmutableLabel builder */ public static ImmutableLabel.Builder builder() { return new ImmutableLabel.Builder(); } /** * Builds instances of type {@link ImmutableLabel ImmutableLabel}. * 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 = "Label", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_ID = 0x1L; private static final long INIT_BIT_IS_DEFAULT = 0x2L; private long initBits = 0x3L; private @Nullable Long id; private @Nullable String nodeId; private @Nullable URI url; private @Nullable String name; private @Nullable String color; private @Nullable String description; private boolean isDefault; private Builder() { } /** * Fill a builder with attribute values from the provided {@code Label} 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(Label instance) { Objects.requireNonNull(instance, "instance"); id(instance.id()); @Nullable String nodeIdValue = instance.nodeId(); if (nodeIdValue != null) { nodeId(nodeIdValue); } @Nullable URI urlValue = instance.url(); if (urlValue != null) { url(urlValue); } @Nullable String nameValue = instance.name(); if (nameValue != null) { name(nameValue); } @Nullable String colorValue = instance.color(); if (colorValue != null) { color(colorValue); } @Nullable String descriptionValue = instance.description(); if (descriptionValue != null) { description(descriptionValue); } isDefault(instance.isDefault()); return this; } /** * Initializes the value for the {@link Label#id() id} attribute. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder id(Long id) { this.id = Objects.requireNonNull(id, "id"); initBits &= ~INIT_BIT_ID; return this; } /** * Initializes the value for the {@link Label#nodeId() nodeId} attribute. * @param nodeId The value for nodeId (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder nodeId(@Nullable String nodeId) { this.nodeId = nodeId; return this; } /** * Initializes the value for the {@link Label#url() url} attribute. * @param url The value for url (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder url(@Nullable URI url) { this.url = url; return this; } /** * Initializes the value for the {@link Label#name() name} attribute. * @param name The value for name (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder name(@Nullable String name) { this.name = name; return this; } /** * Initializes the value for the {@link Label#color() color} attribute. * @param color The value for color (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder color(@Nullable String color) { this.color = color; return this; } /** * Initializes the value for the {@link Label#description() description} attribute. * @param description The value for description (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder description(@Nullable String description) { this.description = description; return this; } /** * Initializes the value for the {@link Label#isDefault() isDefault} attribute. * @param isDefault The value for isDefault * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("default") public final Builder isDefault(boolean isDefault) { this.isDefault = isDefault; initBits &= ~INIT_BIT_IS_DEFAULT; return this; } /** * Builds a new {@link ImmutableLabel ImmutableLabel}. * @return An immutable instance of Label * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableLabel build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableLabel(id, nodeId, url, name, color, description, isDefault); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); if ((initBits & INIT_BIT_IS_DEFAULT) != 0) attributes.add("isDefault"); return "Cannot build Label, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy