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

com.spotify.github.v3.comment.ImmutableCommentReaction Maven / Gradle / Ivy

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

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 com.spotify.github.GitHubInstant;
import com.spotify.github.UpdateTracking;
import com.spotify.github.v3.User;
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 CommentReaction}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableCommentReaction.builder()}. */ @Generated(from = "CommentReaction", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableCommentReaction implements CommentReaction { private final @Nullable GitHubInstant createdAt; private final @Nullable GitHubInstant updatedAt; private final long id; private final User user; private final CommentReactionContent content; private ImmutableCommentReaction( @Nullable GitHubInstant createdAt, @Nullable GitHubInstant updatedAt, long id, User user, CommentReactionContent content) { this.createdAt = createdAt; this.updatedAt = updatedAt; this.id = id; this.user = user; this.content = content; } /** * Created date * @return The date when the issue was created */ @JsonProperty @Override public @Nullable GitHubInstant createdAt() { return createdAt; } /** * Updated date * @return The date when the issue was updated */ @JsonProperty @Override public @Nullable GitHubInstant updatedAt() { return updatedAt; } /** *Reaction ID. */ @JsonProperty @Override public long id() { return id; } /** *Reaction user. */ @JsonProperty @Override public User user() { return user; } /** *Reaction content. */ @JsonProperty @Override public CommentReactionContent content() { return content; } /** * Copy the current immutable object by setting a value for the {@link CommentReaction#createdAt() createdAt} 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 createdAt (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableCommentReaction withCreatedAt(@Nullable GitHubInstant value) { if (this.createdAt == value) return this; return new ImmutableCommentReaction(value, this.updatedAt, this.id, this.user, this.content); } /** * Copy the current immutable object by setting a value for the {@link CommentReaction#updatedAt() updatedAt} 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 updatedAt (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableCommentReaction withUpdatedAt(@Nullable GitHubInstant value) { if (this.updatedAt == value) return this; return new ImmutableCommentReaction(this.createdAt, value, this.id, this.user, this.content); } /** * Copy the current immutable object by setting a value for the {@link CommentReaction#id() id} attribute. * A value equality check is 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 ImmutableCommentReaction withId(long value) { if (this.id == value) return this; return new ImmutableCommentReaction(this.createdAt, this.updatedAt, value, this.user, this.content); } /** * Copy the current immutable object by setting a value for the {@link CommentReaction#user() user} 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 user * @return A modified copy of the {@code this} object */ public final ImmutableCommentReaction withUser(User value) { if (this.user == value) return this; User newValue = Objects.requireNonNull(value, "user"); return new ImmutableCommentReaction(this.createdAt, this.updatedAt, this.id, newValue, this.content); } /** * Copy the current immutable object by setting a value for the {@link CommentReaction#content() content} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for content * @return A modified copy of the {@code this} object */ public final ImmutableCommentReaction withContent(CommentReactionContent value) { CommentReactionContent newValue = Objects.requireNonNull(value, "content"); if (this.content == newValue) return this; return new ImmutableCommentReaction(this.createdAt, this.updatedAt, this.id, this.user, newValue); } /** * This instance is equal to all instances of {@code ImmutableCommentReaction} 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 ImmutableCommentReaction && equalTo(0, (ImmutableCommentReaction) another); } private boolean equalTo(int synthetic, ImmutableCommentReaction another) { return Objects.equals(createdAt, another.createdAt) && Objects.equals(updatedAt, another.updatedAt) && id == another.id && user.equals(another.user) && content.equals(another.content); } /** * Computes a hash code from attributes: {@code createdAt}, {@code updatedAt}, {@code id}, {@code user}, {@code content}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(createdAt); h += (h << 5) + Objects.hashCode(updatedAt); h += (h << 5) + Long.hashCode(id); h += (h << 5) + user.hashCode(); h += (h << 5) + content.hashCode(); return h; } /** * Prints the immutable value {@code CommentReaction} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "CommentReaction{" + "createdAt=" + createdAt + ", updatedAt=" + updatedAt + ", id=" + id + ", user=" + user + ", content=" + content + "}"; } /** * 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 = "CommentReaction", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements CommentReaction { @Nullable GitHubInstant createdAt; @Nullable GitHubInstant updatedAt; long id; boolean idIsSet; @Nullable User user; @Nullable CommentReactionContent content; @JsonProperty public void setCreatedAt(@Nullable GitHubInstant createdAt) { this.createdAt = createdAt; } @JsonProperty public void setUpdatedAt(@Nullable GitHubInstant updatedAt) { this.updatedAt = updatedAt; } @JsonProperty public void setId(long id) { this.id = id; this.idIsSet = true; } @JsonProperty public void setUser(User user) { this.user = user; } @JsonProperty public void setContent(CommentReactionContent content) { this.content = content; } @Override public GitHubInstant createdAt() { throw new UnsupportedOperationException(); } @Override public GitHubInstant updatedAt() { throw new UnsupportedOperationException(); } @Override public long id() { throw new UnsupportedOperationException(); } @Override public User user() { throw new UnsupportedOperationException(); } @Override public CommentReactionContent content() { 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 ImmutableCommentReaction fromJson(Json json) { ImmutableCommentReaction.Builder builder = ImmutableCommentReaction.builder(); if (json.createdAt != null) { builder.createdAt(json.createdAt); } if (json.updatedAt != null) { builder.updatedAt(json.updatedAt); } if (json.idIsSet) { builder.id(json.id); } if (json.user != null) { builder.user(json.user); } if (json.content != null) { builder.content(json.content); } return builder.build(); } /** * Creates an immutable copy of a {@link CommentReaction} 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 CommentReaction instance */ public static ImmutableCommentReaction copyOf(CommentReaction instance) { if (instance instanceof ImmutableCommentReaction) { return (ImmutableCommentReaction) instance; } return ImmutableCommentReaction.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableCommentReaction ImmutableCommentReaction}. *

   * ImmutableCommentReaction.builder()
   *    .createdAt(com.spotify.github.GitHubInstant | null) // nullable {@link CommentReaction#createdAt() createdAt}
   *    .updatedAt(com.spotify.github.GitHubInstant | null) // nullable {@link CommentReaction#updatedAt() updatedAt}
   *    .id(long) // required {@link CommentReaction#id() id}
   *    .user(com.spotify.github.v3.User) // required {@link CommentReaction#user() user}
   *    .content(com.spotify.github.v3.comment.CommentReactionContent) // required {@link CommentReaction#content() content}
   *    .build();
   * 
* @return A new ImmutableCommentReaction builder */ public static ImmutableCommentReaction.Builder builder() { return new ImmutableCommentReaction.Builder(); } /** * Builds instances of type {@link ImmutableCommentReaction ImmutableCommentReaction}. * 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 = "CommentReaction", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_ID = 0x1L; private static final long INIT_BIT_USER = 0x2L; private static final long INIT_BIT_CONTENT = 0x4L; private long initBits = 0x7L; private @Nullable GitHubInstant createdAt; private @Nullable GitHubInstant updatedAt; private long id; private @Nullable User user; private @Nullable CommentReactionContent content; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.spotify.github.v3.comment.CommentReaction} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(CommentReaction instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.spotify.github.UpdateTracking} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(UpdateTracking instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { @Var long bits = 0; if (object instanceof CommentReaction) { CommentReaction instance = (CommentReaction) object; if ((bits & 0x1L) == 0) { @Nullable GitHubInstant createdAtValue = instance.createdAt(); if (createdAtValue != null) { createdAt(createdAtValue); } bits |= 0x1L; } id(instance.id()); user(instance.user()); content(instance.content()); if ((bits & 0x2L) == 0) { @Nullable GitHubInstant updatedAtValue = instance.updatedAt(); if (updatedAtValue != null) { updatedAt(updatedAtValue); } bits |= 0x2L; } } if (object instanceof UpdateTracking) { UpdateTracking instance = (UpdateTracking) object; if ((bits & 0x1L) == 0) { @Nullable GitHubInstant createdAtValue = instance.createdAt(); if (createdAtValue != null) { createdAt(createdAtValue); } bits |= 0x1L; } if ((bits & 0x2L) == 0) { @Nullable GitHubInstant updatedAtValue = instance.updatedAt(); if (updatedAtValue != null) { updatedAt(updatedAtValue); } bits |= 0x2L; } } } /** * Initializes the value for the {@link CommentReaction#createdAt() createdAt} attribute. * @param createdAt The value for createdAt (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder createdAt(@Nullable GitHubInstant createdAt) { this.createdAt = createdAt; return this; } /** * Initializes the value for the {@link CommentReaction#updatedAt() updatedAt} attribute. * @param updatedAt The value for updatedAt (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder updatedAt(@Nullable GitHubInstant updatedAt) { this.updatedAt = updatedAt; return this; } /** * Initializes the value for the {@link CommentReaction#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 = id; initBits &= ~INIT_BIT_ID; return this; } /** * Initializes the value for the {@link CommentReaction#user() user} attribute. * @param user The value for user * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder user(User user) { this.user = Objects.requireNonNull(user, "user"); initBits &= ~INIT_BIT_USER; return this; } /** * Initializes the value for the {@link CommentReaction#content() content} attribute. * @param content The value for content * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder content(CommentReactionContent content) { this.content = Objects.requireNonNull(content, "content"); initBits &= ~INIT_BIT_CONTENT; return this; } /** * Builds a new {@link ImmutableCommentReaction ImmutableCommentReaction}. * @return An immutable instance of CommentReaction * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableCommentReaction build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableCommentReaction(createdAt, updatedAt, id, user, content); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); if ((initBits & INIT_BIT_USER) != 0) attributes.add("user"); if ((initBits & INIT_BIT_CONTENT) != 0) attributes.add("content"); return "Cannot build CommentReaction, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy