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

io.thestencil.iam.api.ImmutableUserMessage Maven / Gradle / Ivy

The newest version!
package io.thestencil.iam.api;

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.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 UserActionsClient.UserMessage}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableUserMessage.builder()}. */ @Generated(from = "UserActionsClient.UserMessage", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableUserMessage implements UserActionsClient.UserMessage { private final String id; private final String created; private final String commentText; private final String userName; private final @Nullable String replyToId; private final @Nullable String taskId; private ImmutableUserMessage( String id, String created, String commentText, String userName, @Nullable String replyToId, @Nullable String taskId) { this.id = id; this.created = created; this.commentText = commentText; this.userName = userName; this.replyToId = replyToId; this.taskId = taskId; } /** * @return The value of the {@code id} attribute */ @JsonProperty("id") @Override public String getId() { return id; } /** * @return The value of the {@code created} attribute */ @JsonProperty("created") @Override public String getCreated() { return created; } /** * @return The value of the {@code commentText} attribute */ @JsonProperty("commentText") @Override public String getCommentText() { return commentText; } /** * @return The value of the {@code userName} attribute */ @JsonProperty("userName") @Override public String getUserName() { return userName; } /** * @return The value of the {@code replyToId} attribute */ @JsonProperty("replyToId") @Override public @Nullable String getReplyToId() { return replyToId; } /** * @return The value of the {@code taskId} attribute */ @JsonProperty("taskId") @Override public @Nullable String getTaskId() { return taskId; } /** * Copy the current immutable object by setting a value for the {@link UserActionsClient.UserMessage#getId() 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 ImmutableUserMessage withId(String value) { String newValue = Objects.requireNonNull(value, "id"); if (this.id.equals(newValue)) return this; return new ImmutableUserMessage(newValue, this.created, this.commentText, this.userName, this.replyToId, this.taskId); } /** * Copy the current immutable object by setting a value for the {@link UserActionsClient.UserMessage#getCreated() created} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for created * @return A modified copy of the {@code this} object */ public final ImmutableUserMessage withCreated(String value) { String newValue = Objects.requireNonNull(value, "created"); if (this.created.equals(newValue)) return this; return new ImmutableUserMessage(this.id, newValue, this.commentText, this.userName, this.replyToId, this.taskId); } /** * Copy the current immutable object by setting a value for the {@link UserActionsClient.UserMessage#getCommentText() commentText} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for commentText * @return A modified copy of the {@code this} object */ public final ImmutableUserMessage withCommentText(String value) { String newValue = Objects.requireNonNull(value, "commentText"); if (this.commentText.equals(newValue)) return this; return new ImmutableUserMessage(this.id, this.created, newValue, this.userName, this.replyToId, this.taskId); } /** * Copy the current immutable object by setting a value for the {@link UserActionsClient.UserMessage#getUserName() userName} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for userName * @return A modified copy of the {@code this} object */ public final ImmutableUserMessage withUserName(String value) { String newValue = Objects.requireNonNull(value, "userName"); if (this.userName.equals(newValue)) return this; return new ImmutableUserMessage(this.id, this.created, this.commentText, newValue, this.replyToId, this.taskId); } /** * Copy the current immutable object by setting a value for the {@link UserActionsClient.UserMessage#getReplyToId() replyToId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for replyToId (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableUserMessage withReplyToId(@Nullable String value) { if (Objects.equals(this.replyToId, value)) return this; return new ImmutableUserMessage(this.id, this.created, this.commentText, this.userName, value, this.taskId); } /** * Copy the current immutable object by setting a value for the {@link UserActionsClient.UserMessage#getTaskId() taskId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for taskId (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableUserMessage withTaskId(@Nullable String value) { if (Objects.equals(this.taskId, value)) return this; return new ImmutableUserMessage(this.id, this.created, this.commentText, this.userName, this.replyToId, value); } /** * This instance is equal to all instances of {@code ImmutableUserMessage} 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 ImmutableUserMessage && equalTo((ImmutableUserMessage) another); } private boolean equalTo(ImmutableUserMessage another) { return id.equals(another.id) && created.equals(another.created) && commentText.equals(another.commentText) && userName.equals(another.userName) && Objects.equals(replyToId, another.replyToId) && Objects.equals(taskId, another.taskId); } /** * Computes a hash code from attributes: {@code id}, {@code created}, {@code commentText}, {@code userName}, {@code replyToId}, {@code taskId}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + id.hashCode(); h += (h << 5) + created.hashCode(); h += (h << 5) + commentText.hashCode(); h += (h << 5) + userName.hashCode(); h += (h << 5) + Objects.hashCode(replyToId); h += (h << 5) + Objects.hashCode(taskId); return h; } /** * Prints the immutable value {@code UserMessage} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("UserMessage") .omitNullValues() .add("id", id) .add("created", created) .add("commentText", commentText) .add("userName", userName) .add("replyToId", replyToId) .add("taskId", taskId) .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 = "UserActionsClient.UserMessage", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements UserActionsClient.UserMessage { @Nullable String id; @Nullable String created; @Nullable String commentText; @Nullable String userName; @Nullable String replyToId; @Nullable String taskId; @JsonProperty("id") public void setId(String id) { this.id = id; } @JsonProperty("created") public void setCreated(String created) { this.created = created; } @JsonProperty("commentText") public void setCommentText(String commentText) { this.commentText = commentText; } @JsonProperty("userName") public void setUserName(String userName) { this.userName = userName; } @JsonProperty("replyToId") public void setReplyToId(@Nullable String replyToId) { this.replyToId = replyToId; } @JsonProperty("taskId") public void setTaskId(@Nullable String taskId) { this.taskId = taskId; } @Override public String getId() { throw new UnsupportedOperationException(); } @Override public String getCreated() { throw new UnsupportedOperationException(); } @Override public String getCommentText() { throw new UnsupportedOperationException(); } @Override public String getUserName() { throw new UnsupportedOperationException(); } @Override public String getReplyToId() { throw new UnsupportedOperationException(); } @Override public String getTaskId() { 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 ImmutableUserMessage fromJson(Json json) { ImmutableUserMessage.Builder builder = ImmutableUserMessage.builder(); if (json.id != null) { builder.id(json.id); } if (json.created != null) { builder.created(json.created); } if (json.commentText != null) { builder.commentText(json.commentText); } if (json.userName != null) { builder.userName(json.userName); } if (json.replyToId != null) { builder.replyToId(json.replyToId); } if (json.taskId != null) { builder.taskId(json.taskId); } return builder.build(); } /** * Creates an immutable copy of a {@link UserActionsClient.UserMessage} 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 UserMessage instance */ public static ImmutableUserMessage copyOf(UserActionsClient.UserMessage instance) { if (instance instanceof ImmutableUserMessage) { return (ImmutableUserMessage) instance; } return ImmutableUserMessage.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableUserMessage ImmutableUserMessage}. *

   * ImmutableUserMessage.builder()
   *    .id(String) // required {@link UserActionsClient.UserMessage#getId() id}
   *    .created(String) // required {@link UserActionsClient.UserMessage#getCreated() created}
   *    .commentText(String) // required {@link UserActionsClient.UserMessage#getCommentText() commentText}
   *    .userName(String) // required {@link UserActionsClient.UserMessage#getUserName() userName}
   *    .replyToId(String | null) // nullable {@link UserActionsClient.UserMessage#getReplyToId() replyToId}
   *    .taskId(String | null) // nullable {@link UserActionsClient.UserMessage#getTaskId() taskId}
   *    .build();
   * 
* @return A new ImmutableUserMessage builder */ public static ImmutableUserMessage.Builder builder() { return new ImmutableUserMessage.Builder(); } /** * Builds instances of type {@link ImmutableUserMessage ImmutableUserMessage}. * 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 = "UserActionsClient.UserMessage", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_ID = 0x1L; private static final long INIT_BIT_CREATED = 0x2L; private static final long INIT_BIT_COMMENT_TEXT = 0x4L; private static final long INIT_BIT_USER_NAME = 0x8L; private long initBits = 0xfL; private @Nullable String id; private @Nullable String created; private @Nullable String commentText; private @Nullable String userName; private @Nullable String replyToId; private @Nullable String taskId; private Builder() { } /** * Fill a builder with attribute values from the provided {@code UserMessage} 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(UserActionsClient.UserMessage instance) { Objects.requireNonNull(instance, "instance"); id(instance.getId()); created(instance.getCreated()); commentText(instance.getCommentText()); userName(instance.getUserName()); @Nullable String replyToIdValue = instance.getReplyToId(); if (replyToIdValue != null) { replyToId(replyToIdValue); } @Nullable String taskIdValue = instance.getTaskId(); if (taskIdValue != null) { taskId(taskIdValue); } return this; } /** * Initializes the value for the {@link UserActionsClient.UserMessage#getId() id} attribute. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("id") public final Builder id(String id) { this.id = Objects.requireNonNull(id, "id"); initBits &= ~INIT_BIT_ID; return this; } /** * Initializes the value for the {@link UserActionsClient.UserMessage#getCreated() created} attribute. * @param created The value for created * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("created") public final Builder created(String created) { this.created = Objects.requireNonNull(created, "created"); initBits &= ~INIT_BIT_CREATED; return this; } /** * Initializes the value for the {@link UserActionsClient.UserMessage#getCommentText() commentText} attribute. * @param commentText The value for commentText * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("commentText") public final Builder commentText(String commentText) { this.commentText = Objects.requireNonNull(commentText, "commentText"); initBits &= ~INIT_BIT_COMMENT_TEXT; return this; } /** * Initializes the value for the {@link UserActionsClient.UserMessage#getUserName() userName} attribute. * @param userName The value for userName * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("userName") public final Builder userName(String userName) { this.userName = Objects.requireNonNull(userName, "userName"); initBits &= ~INIT_BIT_USER_NAME; return this; } /** * Initializes the value for the {@link UserActionsClient.UserMessage#getReplyToId() replyToId} attribute. * @param replyToId The value for replyToId (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("replyToId") public final Builder replyToId(@Nullable String replyToId) { this.replyToId = replyToId; return this; } /** * Initializes the value for the {@link UserActionsClient.UserMessage#getTaskId() taskId} attribute. * @param taskId The value for taskId (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("taskId") public final Builder taskId(@Nullable String taskId) { this.taskId = taskId; return this; } /** * Builds a new {@link ImmutableUserMessage ImmutableUserMessage}. * @return An immutable instance of UserMessage * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableUserMessage build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableUserMessage(id, created, commentText, userName, replyToId, taskId); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); if ((initBits & INIT_BIT_CREATED) != 0) attributes.add("created"); if ((initBits & INIT_BIT_COMMENT_TEXT) != 0) attributes.add("commentText"); if ((initBits & INIT_BIT_USER_NAME) != 0) attributes.add("userName"); return "Cannot build UserMessage, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy