
com.hubspot.slack.client.models.response.ResponseMetadata Maven / Gradle / Ivy
package com.hubspot.slack.client.models.response;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Objects;
import java.util.Optional;
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 ResponseMetadataIF}.
*
* Use the builder to create immutable instances:
* {@code ResponseMetadata.builder()}.
*/
@Generated(from = "ResponseMetadataIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class ResponseMetadata implements ResponseMetadataIF {
private final @Nullable String nextCursor;
private ResponseMetadata(@Nullable String nextCursor) {
this.nextCursor = nextCursor;
}
/**
* @return The value of the {@code nextCursor} attribute
*/
@JsonProperty
@Override
public Optional getNextCursor() {
return Optional.ofNullable(nextCursor);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link ResponseMetadataIF#getNextCursor() nextCursor} attribute.
* @param value The value for nextCursor, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final ResponseMetadata withNextCursor(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.nextCursor, newValue)) return this;
return new ResponseMetadata(newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link ResponseMetadataIF#getNextCursor() nextCursor} 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 nextCursor
* @return A modified copy of {@code this} object
*/
public final ResponseMetadata withNextCursor(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.nextCursor, value)) return this;
return new ResponseMetadata(value);
}
/**
* This instance is equal to all instances of {@code ResponseMetadata} 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 ResponseMetadata
&& equalTo(0, (ResponseMetadata) another);
}
private boolean equalTo(int synthetic, ResponseMetadata another) {
return Objects.equals(nextCursor, another.nextCursor);
}
/**
* Computes a hash code from attributes: {@code nextCursor}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(nextCursor);
return h;
}
/**
* Prints the immutable value {@code ResponseMetadata} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("ResponseMetadata{");
if (nextCursor != null) {
builder.append("nextCursor=").append(nextCursor);
}
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 = "ResponseMetadataIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements ResponseMetadataIF {
@Nullable Optional nextCursor = Optional.empty();
@JsonProperty
public void setNextCursor(Optional nextCursor) {
this.nextCursor = nextCursor;
}
@Override
public Optional getNextCursor() { 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 ResponseMetadata fromJson(Json json) {
ResponseMetadata.Builder builder = ResponseMetadata.builder();
if (json.nextCursor != null) {
builder.setNextCursor(json.nextCursor);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link ResponseMetadataIF} 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 ResponseMetadata instance
*/
public static ResponseMetadata copyOf(ResponseMetadataIF instance) {
if (instance instanceof ResponseMetadata) {
return (ResponseMetadata) instance;
}
return ResponseMetadata.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ResponseMetadata ResponseMetadata}.
*
* ResponseMetadata.builder()
* .setNextCursor(String) // optional {@link ResponseMetadataIF#getNextCursor() nextCursor}
* .build();
*
* @return A new ResponseMetadata builder
*/
public static ResponseMetadata.Builder builder() {
return new ResponseMetadata.Builder();
}
/**
* Builds instances of type {@link ResponseMetadata ResponseMetadata}.
* 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 = "ResponseMetadataIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private @Nullable String nextCursor;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code ResponseMetadataIF} 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
*/
public final Builder from(ResponseMetadataIF instance) {
Objects.requireNonNull(instance, "instance");
Optional nextCursorOptional = instance.getNextCursor();
if (nextCursorOptional.isPresent()) {
setNextCursor(nextCursorOptional);
}
return this;
}
/**
* Initializes the optional value {@link ResponseMetadataIF#getNextCursor() nextCursor} to nextCursor.
* @param nextCursor The value for nextCursor, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setNextCursor(@Nullable String nextCursor) {
this.nextCursor = nextCursor;
return this;
}
/**
* Initializes the optional value {@link ResponseMetadataIF#getNextCursor() nextCursor} to nextCursor.
* @param nextCursor The value for nextCursor
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setNextCursor(Optional nextCursor) {
this.nextCursor = nextCursor.orElse(null);
return this;
}
/**
* Builds a new {@link ResponseMetadata ResponseMetadata}.
* @return An immutable instance of ResponseMetadata
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public ResponseMetadata build() {
return new ResponseMetadata(nextCursor);
}
}
}