com.spotify.github.v3.orgs.requests.ImmutableTeamCreate 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.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 TeamCreate}.
*
* Use the builder to create immutable instances:
* {@code ImmutableTeamCreate.builder()}.
*/
@Generated(from = "TeamCreate", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableTeamCreate implements TeamCreate {
private final @Nullable String name;
private final @Nullable String description;
private final @Nullable String maintainers;
private final @Nullable String repo_names;
private final @Nullable String parent_team_id;
private ImmutableTeamCreate(
@Nullable String name,
@Nullable String description,
@Nullable String maintainers,
@Nullable String repo_names,
@Nullable String parent_team_id) {
this.name = name;
this.description = description;
this.maintainers = maintainers;
this.repo_names = repo_names;
this.parent_team_id = parent_team_id;
}
/**
*The name of the team.
*/
@JsonProperty
@Override
public @Nullable String name() {
return name;
}
/**
*The description of the team.
*/
@JsonProperty
@Override
public Optional description() {
return Optional.ofNullable(description);
}
/**
* List GitHub IDs for organization members who will
* become team maintainers.
*/
@JsonProperty
@Override
public Optional maintainers() {
return Optional.ofNullable(maintainers);
}
/**
*The full name (e.g., "organization-name/repository-name")
* of repositories to add the team to.
*/
@JsonProperty
@Override
public Optional repo_names() {
return Optional.ofNullable(repo_names);
}
/**
*The ID of a team to set as the parent team.
*/
@JsonProperty
@Override
public Optional parent_team_id() {
return Optional.ofNullable(parent_team_id);
}
/**
* Copy the current immutable object by setting a value for the {@link TeamCreate#name() name} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for name (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableTeamCreate withName(@Nullable String value) {
if (Objects.equals(this.name, value)) return this;
return new ImmutableTeamCreate(value, this.description, this.maintainers, this.repo_names, this.parent_team_id);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link TeamCreate#description() description} attribute.
* @param value The value for description
* @return A modified copy of {@code this} object
*/
public final ImmutableTeamCreate withDescription(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "description");
if (Objects.equals(this.description, newValue)) return this;
return new ImmutableTeamCreate(this.name, newValue, this.maintainers, this.repo_names, this.parent_team_id);
}
/**
* Copy the current immutable object by setting an optional value for the {@link TeamCreate#description() description} 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 description
* @return A modified copy of {@code this} object
*/
public final ImmutableTeamCreate withDescription(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return new ImmutableTeamCreate(this.name, value, this.maintainers, this.repo_names, this.parent_team_id);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link TeamCreate#maintainers() maintainers} attribute.
* @param value The value for maintainers
* @return A modified copy of {@code this} object
*/
public final ImmutableTeamCreate withMaintainers(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "maintainers");
if (Objects.equals(this.maintainers, newValue)) return this;
return new ImmutableTeamCreate(this.name, this.description, newValue, this.repo_names, this.parent_team_id);
}
/**
* Copy the current immutable object by setting an optional value for the {@link TeamCreate#maintainers() maintainers} 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 maintainers
* @return A modified copy of {@code this} object
*/
public final ImmutableTeamCreate withMaintainers(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.maintainers, value)) return this;
return new ImmutableTeamCreate(this.name, this.description, value, this.repo_names, this.parent_team_id);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link TeamCreate#repo_names() repo_names} attribute.
* @param value The value for repo_names
* @return A modified copy of {@code this} object
*/
public final ImmutableTeamCreate withRepo_names(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "repo_names");
if (Objects.equals(this.repo_names, newValue)) return this;
return new ImmutableTeamCreate(this.name, this.description, this.maintainers, newValue, this.parent_team_id);
}
/**
* Copy the current immutable object by setting an optional value for the {@link TeamCreate#repo_names() repo_names} 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 repo_names
* @return A modified copy of {@code this} object
*/
public final ImmutableTeamCreate withRepo_names(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.repo_names, value)) return this;
return new ImmutableTeamCreate(this.name, this.description, this.maintainers, value, this.parent_team_id);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link TeamCreate#parent_team_id() parent_team_id} attribute.
* @param value The value for parent_team_id
* @return A modified copy of {@code this} object
*/
public final ImmutableTeamCreate withParent_team_id(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "parent_team_id");
if (Objects.equals(this.parent_team_id, newValue)) return this;
return new ImmutableTeamCreate(this.name, this.description, this.maintainers, this.repo_names, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link TeamCreate#parent_team_id() parent_team_id} 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 parent_team_id
* @return A modified copy of {@code this} object
*/
public final ImmutableTeamCreate withParent_team_id(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.parent_team_id, value)) return this;
return new ImmutableTeamCreate(this.name, this.description, this.maintainers, this.repo_names, value);
}
/**
* This instance is equal to all instances of {@code ImmutableTeamCreate} 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 ImmutableTeamCreate
&& equalTo((ImmutableTeamCreate) another);
}
private boolean equalTo(ImmutableTeamCreate another) {
return Objects.equals(name, another.name)
&& Objects.equals(description, another.description)
&& Objects.equals(maintainers, another.maintainers)
&& Objects.equals(repo_names, another.repo_names)
&& Objects.equals(parent_team_id, another.parent_team_id);
}
/**
* Computes a hash code from attributes: {@code name}, {@code description}, {@code maintainers}, {@code repo_names}, {@code parent_team_id}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + Objects.hashCode(name);
h += (h << 5) + Objects.hashCode(description);
h += (h << 5) + Objects.hashCode(maintainers);
h += (h << 5) + Objects.hashCode(repo_names);
h += (h << 5) + Objects.hashCode(parent_team_id);
return h;
}
/**
* Prints the immutable value {@code TeamCreate} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("TeamCreate{");
if (name != null) {
builder.append("name=").append(name);
}
if (description != null) {
if (builder.length() > 11) builder.append(", ");
builder.append("description=").append(description);
}
if (maintainers != null) {
if (builder.length() > 11) builder.append(", ");
builder.append("maintainers=").append(maintainers);
}
if (repo_names != null) {
if (builder.length() > 11) builder.append(", ");
builder.append("repo_names=").append(repo_names);
}
if (parent_team_id != null) {
if (builder.length() > 11) builder.append(", ");
builder.append("parent_team_id=").append(parent_team_id);
}
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 = "TeamCreate", generator = "Immutables")
@Deprecated
@SuppressWarnings("Immutable")
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements TeamCreate {
@Nullable String name;
@Nullable Optional description = Optional.empty();
@Nullable Optional maintainers = Optional.empty();
@Nullable Optional repo_names = Optional.empty();
@Nullable Optional parent_team_id = Optional.empty();
@JsonProperty
public void setName(@Nullable String name) {
this.name = name;
}
@JsonProperty
public void setDescription(Optional description) {
this.description = description;
}
@JsonProperty
public void setMaintainers(Optional maintainers) {
this.maintainers = maintainers;
}
@JsonProperty
public void setRepo_names(Optional repo_names) {
this.repo_names = repo_names;
}
@JsonProperty
public void setParent_team_id(Optional parent_team_id) {
this.parent_team_id = parent_team_id;
}
@Override
public String name() { throw new UnsupportedOperationException(); }
@Override
public Optional description() { throw new UnsupportedOperationException(); }
@Override
public Optional maintainers() { throw new UnsupportedOperationException(); }
@Override
public Optional repo_names() { throw new UnsupportedOperationException(); }
@Override
public Optional parent_team_id() { 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 ImmutableTeamCreate fromJson(Json json) {
ImmutableTeamCreate.Builder builder = ImmutableTeamCreate.builder();
if (json.name != null) {
builder.name(json.name);
}
if (json.description != null) {
builder.description(json.description);
}
if (json.maintainers != null) {
builder.maintainers(json.maintainers);
}
if (json.repo_names != null) {
builder.repo_names(json.repo_names);
}
if (json.parent_team_id != null) {
builder.parent_team_id(json.parent_team_id);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link TeamCreate} 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 TeamCreate instance
*/
public static ImmutableTeamCreate copyOf(TeamCreate instance) {
if (instance instanceof ImmutableTeamCreate) {
return (ImmutableTeamCreate) instance;
}
return ImmutableTeamCreate.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableTeamCreate ImmutableTeamCreate}.
*
* ImmutableTeamCreate.builder()
* .name(String | null) // nullable {@link TeamCreate#name() name}
* .description(String) // optional {@link TeamCreate#description() description}
* .maintainers(String) // optional {@link TeamCreate#maintainers() maintainers}
* .repo_names(String) // optional {@link TeamCreate#repo_names() repo_names}
* .parent_team_id(String) // optional {@link TeamCreate#parent_team_id() parent_team_id}
* .build();
*
* @return A new ImmutableTeamCreate builder
*/
public static ImmutableTeamCreate.Builder builder() {
return new ImmutableTeamCreate.Builder();
}
/**
* Builds instances of type {@link ImmutableTeamCreate ImmutableTeamCreate}.
* 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 = "TeamCreate", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private @Nullable String name;
private @Nullable String description;
private @Nullable String maintainers;
private @Nullable String repo_names;
private @Nullable String parent_team_id;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code TeamCreate} 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(TeamCreate instance) {
Objects.requireNonNull(instance, "instance");
@Nullable String nameValue = instance.name();
if (nameValue != null) {
name(nameValue);
}
Optional descriptionOptional = instance.description();
if (descriptionOptional.isPresent()) {
description(descriptionOptional);
}
Optional maintainersOptional = instance.maintainers();
if (maintainersOptional.isPresent()) {
maintainers(maintainersOptional);
}
Optional repo_namesOptional = instance.repo_names();
if (repo_namesOptional.isPresent()) {
repo_names(repo_namesOptional);
}
Optional parent_team_idOptional = instance.parent_team_id();
if (parent_team_idOptional.isPresent()) {
parent_team_id(parent_team_idOptional);
}
return this;
}
/**
* Initializes the value for the {@link TeamCreate#name() name} attribute.
* @param name The value for name (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty
public final Builder name(@Nullable String name) {
this.name = name;
return this;
}
/**
* Initializes the optional value {@link TeamCreate#description() description} to description.
* @param description The value for description
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder description(String description) {
this.description = Objects.requireNonNull(description, "description");
return this;
}
/**
* Initializes the optional value {@link TeamCreate#description() description} to description.
* @param description The value for description
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty
public final Builder description(Optional description) {
this.description = description.orElse(null);
return this;
}
/**
* Initializes the optional value {@link TeamCreate#maintainers() maintainers} to maintainers.
* @param maintainers The value for maintainers
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder maintainers(String maintainers) {
this.maintainers = Objects.requireNonNull(maintainers, "maintainers");
return this;
}
/**
* Initializes the optional value {@link TeamCreate#maintainers() maintainers} to maintainers.
* @param maintainers The value for maintainers
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty
public final Builder maintainers(Optional maintainers) {
this.maintainers = maintainers.orElse(null);
return this;
}
/**
* Initializes the optional value {@link TeamCreate#repo_names() repo_names} to repo_names.
* @param repo_names The value for repo_names
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder repo_names(String repo_names) {
this.repo_names = Objects.requireNonNull(repo_names, "repo_names");
return this;
}
/**
* Initializes the optional value {@link TeamCreate#repo_names() repo_names} to repo_names.
* @param repo_names The value for repo_names
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty
public final Builder repo_names(Optional repo_names) {
this.repo_names = repo_names.orElse(null);
return this;
}
/**
* Initializes the optional value {@link TeamCreate#parent_team_id() parent_team_id} to parent_team_id.
* @param parent_team_id The value for parent_team_id
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder parent_team_id(String parent_team_id) {
this.parent_team_id = Objects.requireNonNull(parent_team_id, "parent_team_id");
return this;
}
/**
* Initializes the optional value {@link TeamCreate#parent_team_id() parent_team_id} to parent_team_id.
* @param parent_team_id The value for parent_team_id
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty
public final Builder parent_team_id(Optional parent_team_id) {
this.parent_team_id = parent_team_id.orElse(null);
return this;
}
/**
* Builds a new {@link ImmutableTeamCreate ImmutableTeamCreate}.
* @return An immutable instance of TeamCreate
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableTeamCreate build() {
return new ImmutableTeamCreate(name, description, maintainers, repo_names, parent_team_id);
}
}
}