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

com.spotify.github.v3.prs.ImmutableReviewParameters Maven / Gradle / Ivy

package com.spotify.github.v3.prs;

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.util.ArrayList;
import java.util.List;
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 ReviewParameters}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableReviewParameters.builder()}. */ @Generated(from = "ReviewParameters", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableReviewParameters extends ReviewParameters { private final @Nullable String commitId; private final @Nullable String body; private final String event; private ImmutableReviewParameters( @Nullable String commitId, @Nullable String body, String event) { this.commitId = commitId; this.body = body; this.event = event; } /** * SHA of the commit that needs a review. If not the latest, the review may be outdated. * Defaults to the most recent commit in the PR when you do not specify a value. * @return the optional commitId. */ @JsonProperty @Override public Optional commitId() { return Optional.ofNullable(commitId); } /** * **required** when using REQUEST_CHANGES or COMMENT for the event. * @return the optional body for REQUEST_CHANGES or COMMENT events. */ @JsonProperty @Override public Optional body() { return Optional.ofNullable(body); } /** * Review action you want to perform. Should be one of: APPROVE, REQUEST_CHANGES or COMMENT. * @return the review action to perform. */ @JsonProperty @Override public String event() { return event; } /** * Copy the current immutable object by setting a present value for the optional {@link ReviewParameters#commitId() commitId} attribute. * @param value The value for commitId * @return A modified copy of {@code this} object */ public final ImmutableReviewParameters withCommitId(String value) { @Nullable String newValue = Objects.requireNonNull(value, "commitId"); if (Objects.equals(this.commitId, newValue)) return this; return new ImmutableReviewParameters(newValue, this.body, this.event); } /** * Copy the current immutable object by setting an optional value for the {@link ReviewParameters#commitId() commitId} 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 commitId * @return A modified copy of {@code this} object */ public final ImmutableReviewParameters withCommitId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.commitId, value)) return this; return new ImmutableReviewParameters(value, this.body, this.event); } /** * Copy the current immutable object by setting a present value for the optional {@link ReviewParameters#body() body} attribute. * @param value The value for body * @return A modified copy of {@code this} object */ public final ImmutableReviewParameters withBody(String value) { @Nullable String newValue = Objects.requireNonNull(value, "body"); if (Objects.equals(this.body, newValue)) return this; return new ImmutableReviewParameters(this.commitId, newValue, this.event); } /** * Copy the current immutable object by setting an optional value for the {@link ReviewParameters#body() body} 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 body * @return A modified copy of {@code this} object */ public final ImmutableReviewParameters withBody(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.body, value)) return this; return new ImmutableReviewParameters(this.commitId, value, this.event); } /** * Copy the current immutable object by setting a value for the {@link ReviewParameters#event() event} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for event * @return A modified copy of the {@code this} object */ public final ImmutableReviewParameters withEvent(String value) { String newValue = Objects.requireNonNull(value, "event"); if (this.event.equals(newValue)) return this; return new ImmutableReviewParameters(this.commitId, this.body, newValue); } /** * This instance is equal to all instances of {@code ImmutableReviewParameters} 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 ImmutableReviewParameters && equalTo((ImmutableReviewParameters) another); } private boolean equalTo(ImmutableReviewParameters another) { return Objects.equals(commitId, another.commitId) && Objects.equals(body, another.body) && event.equals(another.event); } /** * Computes a hash code from attributes: {@code commitId}, {@code body}, {@code event}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(commitId); h += (h << 5) + Objects.hashCode(body); h += (h << 5) + event.hashCode(); return h; } /** * Prints the immutable value {@code ReviewParameters} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ReviewParameters{"); if (commitId != null) { builder.append("commitId=").append(commitId); } if (body != null) { if (builder.length() > 17) builder.append(", "); builder.append("body=").append(body); } if (builder.length() > 17) builder.append(", "); builder.append("event=").append(event); return builder.append("}").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 = "ReviewParameters", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json extends ReviewParameters { @Nullable Optional commitId = Optional.empty(); @Nullable Optional body = Optional.empty(); @Nullable String event; @JsonProperty public void setCommitId(Optional commitId) { this.commitId = commitId; } @JsonProperty public void setBody(Optional body) { this.body = body; } @JsonProperty public void setEvent(String event) { this.event = event; } @Override public Optional commitId() { throw new UnsupportedOperationException(); } @Override public Optional body() { throw new UnsupportedOperationException(); } @Override public String event() { 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 ImmutableReviewParameters fromJson(Json json) { ImmutableReviewParameters.Builder builder = ImmutableReviewParameters.builder(); if (json.commitId != null) { builder.commitId(json.commitId); } if (json.body != null) { builder.body(json.body); } if (json.event != null) { builder.event(json.event); } return builder.build(); } /** * Creates an immutable copy of a {@link ReviewParameters} 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 ReviewParameters instance */ public static ImmutableReviewParameters copyOf(ReviewParameters instance) { if (instance instanceof ImmutableReviewParameters) { return (ImmutableReviewParameters) instance; } return ImmutableReviewParameters.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableReviewParameters ImmutableReviewParameters}. *

   * ImmutableReviewParameters.builder()
   *    .commitId(String) // optional {@link ReviewParameters#commitId() commitId}
   *    .body(String) // optional {@link ReviewParameters#body() body}
   *    .event(String) // required {@link ReviewParameters#event() event}
   *    .build();
   * 
* @return A new ImmutableReviewParameters builder */ public static ImmutableReviewParameters.Builder builder() { return new ImmutableReviewParameters.Builder(); } /** * Builds instances of type {@link ImmutableReviewParameters ImmutableReviewParameters}. * 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 = "ReviewParameters", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_EVENT = 0x1L; private long initBits = 0x1L; private @Nullable String commitId; private @Nullable String body; private @Nullable String event; private Builder() { } /** * Fill a builder with attribute values from the provided {@code ReviewParameters} 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(ReviewParameters instance) { Objects.requireNonNull(instance, "instance"); Optional commitIdOptional = instance.commitId(); if (commitIdOptional.isPresent()) { commitId(commitIdOptional); } Optional bodyOptional = instance.body(); if (bodyOptional.isPresent()) { body(bodyOptional); } event(instance.event()); return this; } /** * Initializes the optional value {@link ReviewParameters#commitId() commitId} to commitId. * @param commitId The value for commitId * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder commitId(String commitId) { this.commitId = Objects.requireNonNull(commitId, "commitId"); return this; } /** * Initializes the optional value {@link ReviewParameters#commitId() commitId} to commitId. * @param commitId The value for commitId * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder commitId(Optional commitId) { this.commitId = commitId.orElse(null); return this; } /** * Initializes the optional value {@link ReviewParameters#body() body} to body. * @param body The value for body * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final Builder body(String body) { this.body = Objects.requireNonNull(body, "body"); return this; } /** * Initializes the optional value {@link ReviewParameters#body() body} to body. * @param body The value for body * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder body(Optional body) { this.body = body.orElse(null); return this; } /** * Initializes the value for the {@link ReviewParameters#event() event} attribute. * @param event The value for event * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder event(String event) { this.event = Objects.requireNonNull(event, "event"); initBits &= ~INIT_BIT_EVENT; return this; } /** * Builds a new {@link ImmutableReviewParameters ImmutableReviewParameters}. * @return An immutable instance of ReviewParameters * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableReviewParameters build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableReviewParameters(commitId, body, event); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_EVENT) != 0) attributes.add("event"); return "Cannot build ReviewParameters, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy