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

com.spotify.github.v3.repos.requests.ImmutableFileCreate Maven / Gradle / Ivy

The newest version!
package com.spotify.github.v3.repos.requests;

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 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 FileCreate}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableFileCreate.builder()}. */ @Generated(from = "FileCreate", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableFileCreate implements FileCreate { private final String message; private final String content; private final @Nullable String branch; private ImmutableFileCreate( String message, String content, @Nullable String branch) { this.message = message; this.content = content; this.branch = branch; } /** *The commit message */ @JsonProperty @Override public String message() { return message; } /** *The new file content, using Base64 encoding */ @JsonProperty @Override public String content() { return content; } /** *The branch name. Default: the repository’s default branch */ @JsonProperty @Override public @Nullable String branch() { return branch; } /** * Copy the current immutable object by setting a value for the {@link FileCreate#message() message} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for message * @return A modified copy of the {@code this} object */ public final ImmutableFileCreate withMessage(String value) { String newValue = Objects.requireNonNull(value, "message"); if (this.message.equals(newValue)) return this; return new ImmutableFileCreate(newValue, this.content, this.branch); } /** * Copy the current immutable object by setting a value for the {@link FileCreate#content() content} attribute. * An equals check 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 ImmutableFileCreate withContent(String value) { String newValue = Objects.requireNonNull(value, "content"); if (this.content.equals(newValue)) return this; return new ImmutableFileCreate(this.message, newValue, this.branch); } /** * Copy the current immutable object by setting a value for the {@link FileCreate#branch() branch} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for branch (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableFileCreate withBranch(@Nullable String value) { if (Objects.equals(this.branch, value)) return this; return new ImmutableFileCreate(this.message, this.content, value); } /** * This instance is equal to all instances of {@code ImmutableFileCreate} 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 ImmutableFileCreate && equalTo(0, (ImmutableFileCreate) another); } private boolean equalTo(int synthetic, ImmutableFileCreate another) { return message.equals(another.message) && content.equals(another.content) && Objects.equals(branch, another.branch); } /** * Computes a hash code from attributes: {@code message}, {@code content}, {@code branch}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + message.hashCode(); h += (h << 5) + content.hashCode(); h += (h << 5) + Objects.hashCode(branch); return h; } /** * Prints the immutable value {@code FileCreate} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "FileCreate{" + "message=" + message + ", content=" + content + ", branch=" + branch + "}"; } /** * 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 = "FileCreate", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements FileCreate { @Nullable String message; @Nullable String content; @Nullable String branch; @JsonProperty public void setMessage(String message) { this.message = message; } @JsonProperty public void setContent(String content) { this.content = content; } @JsonProperty public void setBranch(@Nullable String branch) { this.branch = branch; } @Override public String message() { throw new UnsupportedOperationException(); } @Override public String content() { throw new UnsupportedOperationException(); } @Override public String branch() { 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 ImmutableFileCreate fromJson(Json json) { ImmutableFileCreate.Builder builder = ImmutableFileCreate.builder(); if (json.message != null) { builder.message(json.message); } if (json.content != null) { builder.content(json.content); } if (json.branch != null) { builder.branch(json.branch); } return builder.build(); } /** * Creates an immutable copy of a {@link FileCreate} 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 FileCreate instance */ public static ImmutableFileCreate copyOf(FileCreate instance) { if (instance instanceof ImmutableFileCreate) { return (ImmutableFileCreate) instance; } return ImmutableFileCreate.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableFileCreate ImmutableFileCreate}. *

   * ImmutableFileCreate.builder()
   *    .message(String) // required {@link FileCreate#message() message}
   *    .content(String) // required {@link FileCreate#content() content}
   *    .branch(String | null) // nullable {@link FileCreate#branch() branch}
   *    .build();
   * 
* @return A new ImmutableFileCreate builder */ public static ImmutableFileCreate.Builder builder() { return new ImmutableFileCreate.Builder(); } /** * Builds instances of type {@link ImmutableFileCreate ImmutableFileCreate}. * 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 = "FileCreate", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_MESSAGE = 0x1L; private static final long INIT_BIT_CONTENT = 0x2L; private long initBits = 0x3L; private @Nullable String message; private @Nullable String content; private @Nullable String branch; private Builder() { } /** * Fill a builder with attribute values from the provided {@code FileCreate} 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(FileCreate instance) { Objects.requireNonNull(instance, "instance"); message(instance.message()); content(instance.content()); @Nullable String branchValue = instance.branch(); if (branchValue != null) { branch(branchValue); } return this; } /** * Initializes the value for the {@link FileCreate#message() message} attribute. * @param message The value for message * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder message(String message) { this.message = Objects.requireNonNull(message, "message"); initBits &= ~INIT_BIT_MESSAGE; return this; } /** * Initializes the value for the {@link FileCreate#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(String content) { this.content = Objects.requireNonNull(content, "content"); initBits &= ~INIT_BIT_CONTENT; return this; } /** * Initializes the value for the {@link FileCreate#branch() branch} attribute. * @param branch The value for branch (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty public final Builder branch(@Nullable String branch) { this.branch = branch; return this; } /** * Builds a new {@link ImmutableFileCreate ImmutableFileCreate}. * @return An immutable instance of FileCreate * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableFileCreate build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableFileCreate(message, content, branch); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_MESSAGE) != 0) attributes.add("message"); if ((initBits & INIT_BIT_CONTENT) != 0) attributes.add("content"); return "Cannot build FileCreate, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy