com.spotify.github.v3.orgs.requests.ImmutableTeamRepoPermissionUpdate Maven / Gradle / Ivy
package com.spotify.github.v3.orgs.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 TeamRepoPermissionUpdate}.
*
* Use the builder to create immutable instances:
* {@code ImmutableTeamRepoPermissionUpdate.builder()}.
*/
@Generated(from = "TeamRepoPermissionUpdate", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableTeamRepoPermissionUpdate
implements TeamRepoPermissionUpdate {
private final String org;
private final String repo;
private final String teamSlug;
private final String permission;
private ImmutableTeamRepoPermissionUpdate(String org, String repo, String teamSlug, String permission) {
this.org = org;
this.repo = repo;
this.teamSlug = teamSlug;
this.permission = permission;
}
/**
* @return The value of the {@code org} attribute
*/
@JsonProperty
@Override
public String org() {
return org;
}
/**
* @return The value of the {@code repo} attribute
*/
@JsonProperty
@Override
public String repo() {
return repo;
}
/**
* @return The value of the {@code teamSlug} attribute
*/
@JsonProperty
@Override
public String teamSlug() {
return teamSlug;
}
/**
* @return The value of the {@code permission} attribute
*/
@JsonProperty
@Override
public String permission() {
return permission;
}
/**
* Copy the current immutable object by setting a value for the {@link TeamRepoPermissionUpdate#org() org} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for org
* @return A modified copy of the {@code this} object
*/
public final ImmutableTeamRepoPermissionUpdate withOrg(String value) {
String newValue = Objects.requireNonNull(value, "org");
if (this.org.equals(newValue)) return this;
return new ImmutableTeamRepoPermissionUpdate(newValue, this.repo, this.teamSlug, this.permission);
}
/**
* Copy the current immutable object by setting a value for the {@link TeamRepoPermissionUpdate#repo() repo} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for repo
* @return A modified copy of the {@code this} object
*/
public final ImmutableTeamRepoPermissionUpdate withRepo(String value) {
String newValue = Objects.requireNonNull(value, "repo");
if (this.repo.equals(newValue)) return this;
return new ImmutableTeamRepoPermissionUpdate(this.org, newValue, this.teamSlug, this.permission);
}
/**
* Copy the current immutable object by setting a value for the {@link TeamRepoPermissionUpdate#teamSlug() teamSlug} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for teamSlug
* @return A modified copy of the {@code this} object
*/
public final ImmutableTeamRepoPermissionUpdate withTeamSlug(String value) {
String newValue = Objects.requireNonNull(value, "teamSlug");
if (this.teamSlug.equals(newValue)) return this;
return new ImmutableTeamRepoPermissionUpdate(this.org, this.repo, newValue, this.permission);
}
/**
* Copy the current immutable object by setting a value for the {@link TeamRepoPermissionUpdate#permission() permission} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for permission
* @return A modified copy of the {@code this} object
*/
public final ImmutableTeamRepoPermissionUpdate withPermission(String value) {
String newValue = Objects.requireNonNull(value, "permission");
if (this.permission.equals(newValue)) return this;
return new ImmutableTeamRepoPermissionUpdate(this.org, this.repo, this.teamSlug, newValue);
}
/**
* This instance is equal to all instances of {@code ImmutableTeamRepoPermissionUpdate} 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 ImmutableTeamRepoPermissionUpdate
&& equalTo(0, (ImmutableTeamRepoPermissionUpdate) another);
}
private boolean equalTo(int synthetic, ImmutableTeamRepoPermissionUpdate another) {
return org.equals(another.org)
&& repo.equals(another.repo)
&& teamSlug.equals(another.teamSlug)
&& permission.equals(another.permission);
}
/**
* Computes a hash code from attributes: {@code org}, {@code repo}, {@code teamSlug}, {@code permission}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + org.hashCode();
h += (h << 5) + repo.hashCode();
h += (h << 5) + teamSlug.hashCode();
h += (h << 5) + permission.hashCode();
return h;
}
/**
* Prints the immutable value {@code TeamRepoPermissionUpdate} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "TeamRepoPermissionUpdate{"
+ "org=" + org
+ ", repo=" + repo
+ ", teamSlug=" + teamSlug
+ ", permission=" + permission
+ "}";
}
/**
* 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 = "TeamRepoPermissionUpdate", generator = "Immutables")
@Deprecated
@SuppressWarnings("Immutable")
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements TeamRepoPermissionUpdate {
@Nullable String org;
@Nullable String repo;
@Nullable String teamSlug;
@Nullable String permission;
@JsonProperty
public void setOrg(String org) {
this.org = org;
}
@JsonProperty
public void setRepo(String repo) {
this.repo = repo;
}
@JsonProperty
public void setTeamSlug(String teamSlug) {
this.teamSlug = teamSlug;
}
@JsonProperty
public void setPermission(String permission) {
this.permission = permission;
}
@Override
public String org() { throw new UnsupportedOperationException(); }
@Override
public String repo() { throw new UnsupportedOperationException(); }
@Override
public String teamSlug() { throw new UnsupportedOperationException(); }
@Override
public String permission() { 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 ImmutableTeamRepoPermissionUpdate fromJson(Json json) {
ImmutableTeamRepoPermissionUpdate.Builder builder = ImmutableTeamRepoPermissionUpdate.builder();
if (json.org != null) {
builder.org(json.org);
}
if (json.repo != null) {
builder.repo(json.repo);
}
if (json.teamSlug != null) {
builder.teamSlug(json.teamSlug);
}
if (json.permission != null) {
builder.permission(json.permission);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link TeamRepoPermissionUpdate} 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 TeamRepoPermissionUpdate instance
*/
public static ImmutableTeamRepoPermissionUpdate copyOf(TeamRepoPermissionUpdate instance) {
if (instance instanceof ImmutableTeamRepoPermissionUpdate) {
return (ImmutableTeamRepoPermissionUpdate) instance;
}
return ImmutableTeamRepoPermissionUpdate.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableTeamRepoPermissionUpdate ImmutableTeamRepoPermissionUpdate}.
*
* ImmutableTeamRepoPermissionUpdate.builder()
* .org(String) // required {@link TeamRepoPermissionUpdate#org() org}
* .repo(String) // required {@link TeamRepoPermissionUpdate#repo() repo}
* .teamSlug(String) // required {@link TeamRepoPermissionUpdate#teamSlug() teamSlug}
* .permission(String) // required {@link TeamRepoPermissionUpdate#permission() permission}
* .build();
*
* @return A new ImmutableTeamRepoPermissionUpdate builder
*/
public static ImmutableTeamRepoPermissionUpdate.Builder builder() {
return new ImmutableTeamRepoPermissionUpdate.Builder();
}
/**
* Builds instances of type {@link ImmutableTeamRepoPermissionUpdate ImmutableTeamRepoPermissionUpdate}.
* 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 = "TeamRepoPermissionUpdate", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_ORG = 0x1L;
private static final long INIT_BIT_REPO = 0x2L;
private static final long INIT_BIT_TEAM_SLUG = 0x4L;
private static final long INIT_BIT_PERMISSION = 0x8L;
private long initBits = 0xfL;
private @Nullable String org;
private @Nullable String repo;
private @Nullable String teamSlug;
private @Nullable String permission;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code TeamRepoPermissionUpdate} 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(TeamRepoPermissionUpdate instance) {
Objects.requireNonNull(instance, "instance");
org(instance.org());
repo(instance.repo());
teamSlug(instance.teamSlug());
permission(instance.permission());
return this;
}
/**
* Initializes the value for the {@link TeamRepoPermissionUpdate#org() org} attribute.
* @param org The value for org
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty
public final Builder org(String org) {
this.org = Objects.requireNonNull(org, "org");
initBits &= ~INIT_BIT_ORG;
return this;
}
/**
* Initializes the value for the {@link TeamRepoPermissionUpdate#repo() repo} attribute.
* @param repo The value for repo
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty
public final Builder repo(String repo) {
this.repo = Objects.requireNonNull(repo, "repo");
initBits &= ~INIT_BIT_REPO;
return this;
}
/**
* Initializes the value for the {@link TeamRepoPermissionUpdate#teamSlug() teamSlug} attribute.
* @param teamSlug The value for teamSlug
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty
public final Builder teamSlug(String teamSlug) {
this.teamSlug = Objects.requireNonNull(teamSlug, "teamSlug");
initBits &= ~INIT_BIT_TEAM_SLUG;
return this;
}
/**
* Initializes the value for the {@link TeamRepoPermissionUpdate#permission() permission} attribute.
* @param permission The value for permission
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty
public final Builder permission(String permission) {
this.permission = Objects.requireNonNull(permission, "permission");
initBits &= ~INIT_BIT_PERMISSION;
return this;
}
/**
* Builds a new {@link ImmutableTeamRepoPermissionUpdate ImmutableTeamRepoPermissionUpdate}.
* @return An immutable instance of TeamRepoPermissionUpdate
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableTeamRepoPermissionUpdate build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableTeamRepoPermissionUpdate(org, repo, teamSlug, permission);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_ORG) != 0) attributes.add("org");
if ((initBits & INIT_BIT_REPO) != 0) attributes.add("repo");
if ((initBits & INIT_BIT_TEAM_SLUG) != 0) attributes.add("teamSlug");
if ((initBits & INIT_BIT_PERMISSION) != 0) attributes.add("permission");
return "Cannot build TeamRepoPermissionUpdate, some of required attributes are not set " + attributes;
}
}
}