com.treasuredata.client.model.ImmutableTDSavedQueryStartRequest Maven / Gradle / Ivy
Show all versions of td-client Show documentation
package com.treasuredata.client.model;
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.common.base.MoreObjects;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Date;
import java.util.List;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link TDSavedQueryStartRequest}.
*
* Use the builder to create immutable instances:
* {@code ImmutableTDSavedQueryStartRequest.builder()}.
*/
@SuppressWarnings("all")
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "TDSavedQueryStartRequest"})
@Immutable
final class ImmutableTDSavedQueryStartRequest
extends TDSavedQueryStartRequest {
private final String name;
private final Optional id;
private final Date scheduledTime;
private final Optional num;
private final Optional domainKey;
private ImmutableTDSavedQueryStartRequest(
String name,
Optional id,
Date scheduledTime,
Optional num,
Optional domainKey) {
this.name = name;
this.id = id;
this.scheduledTime = scheduledTime;
this.num = num;
this.domainKey = domainKey;
}
/**
* @return The value of the {@code name} attribute
*/
@JsonProperty("name")
@Override
public String name() {
return name;
}
/**
* @return The value of the {@code id} attribute
*/
@JsonProperty("id")
@Override
public Optional id() {
return id;
}
/**
* @return The value of the {@code scheduledTime} attribute
*/
@JsonProperty("scheduledTime")
@Override
public Date scheduledTime() {
return scheduledTime;
}
/**
* @return The value of the {@code num} attribute
*/
@JsonProperty("num")
@Override
public Optional num() {
return num;
}
/**
* @return The value of the {@code domainKey} attribute
*/
@JsonProperty("domainKey")
@Override
public Optional domainKey() {
return domainKey;
}
/**
* Copy the current immutable object by setting a value for the {@link TDSavedQueryStartRequest#name() name} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param name A new value for name
* @return A modified copy of the {@code this} object
*/
public final ImmutableTDSavedQueryStartRequest withName(String name) {
if (this.name.equals(name)) return this;
String newValue = Preconditions.checkNotNull(name, "name");
return new ImmutableTDSavedQueryStartRequest(newValue, this.id, this.scheduledTime, this.num, this.domainKey);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link TDSavedQueryStartRequest#id() id} attribute.
* @param value The value for id
* @return A modified copy of {@code this} object
*/
public final ImmutableTDSavedQueryStartRequest withId(long value) {
Optional newValue = Optional.of(value);
if (this.id.equals(newValue)) return this;
return new ImmutableTDSavedQueryStartRequest(this.name, newValue, this.scheduledTime, this.num, this.domainKey);
}
/**
* Copy the current immutable object by setting an optional value for the {@link TDSavedQueryStartRequest#id() id} attribute.
* An equality check is used to prevent copying of the same value by returning {@code this}.
* @param optional A value for id
* @return A modified copy of {@code this} object
*/
public final ImmutableTDSavedQueryStartRequest withId(Optional optional) {
Optional value = Preconditions.checkNotNull(optional, "id");
if (this.id.equals(value)) return this;
return new ImmutableTDSavedQueryStartRequest(this.name, value, this.scheduledTime, this.num, this.domainKey);
}
/**
* Copy the current immutable object by setting a value for the {@link TDSavedQueryStartRequest#scheduledTime() scheduledTime} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param scheduledTime A new value for scheduledTime
* @return A modified copy of the {@code this} object
*/
public final ImmutableTDSavedQueryStartRequest withScheduledTime(Date scheduledTime) {
if (this.scheduledTime == scheduledTime) return this;
Date newValue = Preconditions.checkNotNull(scheduledTime, "scheduledTime");
return new ImmutableTDSavedQueryStartRequest(this.name, this.id, newValue, this.num, this.domainKey);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link TDSavedQueryStartRequest#num() num} attribute.
* @param value The value for num
* @return A modified copy of {@code this} object
*/
public final ImmutableTDSavedQueryStartRequest withNum(int value) {
Optional newValue = Optional.of(value);
if (this.num.equals(newValue)) return this;
return new ImmutableTDSavedQueryStartRequest(this.name, this.id, this.scheduledTime, newValue, this.domainKey);
}
/**
* Copy the current immutable object by setting an optional value for the {@link TDSavedQueryStartRequest#num() num} attribute.
* An equality check is used to prevent copying of the same value by returning {@code this}.
* @param optional A value for num
* @return A modified copy of {@code this} object
*/
public final ImmutableTDSavedQueryStartRequest withNum(Optional optional) {
Optional value = Preconditions.checkNotNull(optional, "num");
if (this.num.equals(value)) return this;
return new ImmutableTDSavedQueryStartRequest(this.name, this.id, this.scheduledTime, value, this.domainKey);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link TDSavedQueryStartRequest#domainKey() domainKey} attribute.
* @param value The value for domainKey
* @return A modified copy of {@code this} object
*/
public final ImmutableTDSavedQueryStartRequest withDomainKey(String value) {
Optional newValue = Optional.of(value);
if (this.domainKey.equals(newValue)) return this;
return new ImmutableTDSavedQueryStartRequest(this.name, this.id, this.scheduledTime, this.num, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link TDSavedQueryStartRequest#domainKey() domainKey} attribute.
* An equality check is used to prevent copying of the same value by returning {@code this}.
* @param optional A value for domainKey
* @return A modified copy of {@code this} object
*/
public final ImmutableTDSavedQueryStartRequest withDomainKey(Optional optional) {
Optional value = Preconditions.checkNotNull(optional, "domainKey");
if (this.domainKey.equals(value)) return this;
return new ImmutableTDSavedQueryStartRequest(this.name, this.id, this.scheduledTime, this.num, value);
}
/**
* This instance is equal to all instances of {@code ImmutableTDSavedQueryStartRequest} 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 ImmutableTDSavedQueryStartRequest
&& equalTo((ImmutableTDSavedQueryStartRequest) another);
}
private boolean equalTo(ImmutableTDSavedQueryStartRequest another) {
return name.equals(another.name)
&& id.equals(another.id)
&& scheduledTime.equals(another.scheduledTime)
&& num.equals(another.num)
&& domainKey.equals(another.domainKey);
}
/**
* Computes a hash code from attributes: {@code name}, {@code id}, {@code scheduledTime}, {@code num}, {@code domainKey}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 31;
h = h * 17 + name.hashCode();
h = h * 17 + id.hashCode();
h = h * 17 + scheduledTime.hashCode();
h = h * 17 + num.hashCode();
h = h * 17 + domainKey.hashCode();
return h;
}
/**
* Prints the immutable value {@code TDSavedQueryStartRequest} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("TDSavedQueryStartRequest")
.omitNullValues()
.add("name", name)
.add("id", id.orNull())
.add("scheduledTime", scheduledTime)
.add("num", num.orNull())
.add("domainKey", domainKey.orNull())
.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
*/
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json extends TDSavedQueryStartRequest {
@Nullable String name;
Optional id = Optional.absent();
@Nullable Date scheduledTime;
Optional num = Optional.absent();
Optional domainKey = Optional.absent();
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
@JsonProperty("id")
public void setId(Optional id) {
this.id = id;
}
@JsonProperty("scheduledTime")
public void setScheduledTime(Date scheduledTime) {
this.scheduledTime = scheduledTime;
}
@JsonProperty("num")
public void setNum(Optional num) {
this.num = num;
}
@JsonProperty("domainKey")
public void setDomainKey(Optional domainKey) {
this.domainKey = domainKey;
}
@Override
public String name() { throw new UnsupportedOperationException(); }
@Override
public Optional id() { throw new UnsupportedOperationException(); }
@Override
public Date scheduledTime() { throw new UnsupportedOperationException(); }
@Override
public Optional num() { throw new UnsupportedOperationException(); }
@Override
public Optional domainKey() { 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
static ImmutableTDSavedQueryStartRequest fromJson(Json json) {
ImmutableTDSavedQueryStartRequest.Builder builder = ImmutableTDSavedQueryStartRequest.builder();
if (json.name != null) {
builder.name(json.name);
}
if (json.id != null) {
builder.id(json.id);
}
if (json.scheduledTime != null) {
builder.scheduledTime(json.scheduledTime);
}
if (json.num != null) {
builder.num(json.num);
}
if (json.domainKey != null) {
builder.domainKey(json.domainKey);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link TDSavedQueryStartRequest} 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 TDSavedQueryStartRequest instance
*/
public static ImmutableTDSavedQueryStartRequest copyOf(TDSavedQueryStartRequest instance) {
if (instance instanceof ImmutableTDSavedQueryStartRequest) {
return (ImmutableTDSavedQueryStartRequest) instance;
}
return ImmutableTDSavedQueryStartRequest.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableTDSavedQueryStartRequest ImmutableTDSavedQueryStartRequest}.
* @return A new ImmutableTDSavedQueryStartRequest builder
*/
public static ImmutableTDSavedQueryStartRequest.Builder builder() {
return new ImmutableTDSavedQueryStartRequest.Builder();
}
/**
* Builds instances of type {@link ImmutableTDSavedQueryStartRequest ImmutableTDSavedQueryStartRequest}.
* 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.
*/
@NotThreadSafe
static final class Builder
implements TDSavedQueryStartRequest.Builder {
private static final long INIT_BIT_NAME = 0x1L;
private static final long INIT_BIT_SCHEDULED_TIME = 0x2L;
private long initBits = 0x3L;
private @Nullable String name;
private Optional id = Optional.absent();
private @Nullable Date scheduledTime;
private Optional num = Optional.absent();
private Optional domainKey = Optional.absent();
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code TDSavedQueryStartRequest} 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(TDSavedQueryStartRequest instance) {
Preconditions.checkNotNull(instance, "instance");
name(instance.name());
Optional idOptional = instance.id();
if (idOptional.isPresent()) {
id(idOptional);
}
scheduledTime(instance.scheduledTime());
Optional numOptional = instance.num();
if (numOptional.isPresent()) {
num(numOptional);
}
Optional domainKeyOptional = instance.domainKey();
if (domainKeyOptional.isPresent()) {
domainKey(domainKeyOptional);
}
return this;
}
/**
* Initializes the value for the {@link TDSavedQueryStartRequest#name() name} attribute.
* @param name The value for name
* @return {@code this} builder for use in a chained invocation
*/
public final Builder name(String name) {
this.name = Preconditions.checkNotNull(name, "name");
initBits &= ~INIT_BIT_NAME;
return this;
}
/**
* Initializes the optional value {@link TDSavedQueryStartRequest#id() id} to id.
* @param id The value for id
* @return {@code this} builder for chained invocation
*/
public final Builder id(long id) {
this.id = Optional.of(id);
return this;
}
/**
* Initializes the optional value {@link TDSavedQueryStartRequest#id() id} to id.
* @param id The value for id
* @return {@code this} builder for use in a chained invocation
*/
public final Builder id(Optional id) {
this.id = Preconditions.checkNotNull(id, "id");
return this;
}
/**
* Initializes the value for the {@link TDSavedQueryStartRequest#scheduledTime() scheduledTime} attribute.
* @param scheduledTime The value for scheduledTime
* @return {@code this} builder for use in a chained invocation
*/
public final Builder scheduledTime(Date scheduledTime) {
this.scheduledTime = Preconditions.checkNotNull(scheduledTime, "scheduledTime");
initBits &= ~INIT_BIT_SCHEDULED_TIME;
return this;
}
/**
* Initializes the optional value {@link TDSavedQueryStartRequest#num() num} to num.
* @param num The value for num
* @return {@code this} builder for chained invocation
*/
public final Builder num(int num) {
this.num = Optional.of(num);
return this;
}
/**
* Initializes the optional value {@link TDSavedQueryStartRequest#num() num} to num.
* @param num The value for num
* @return {@code this} builder for use in a chained invocation
*/
public final Builder num(Optional num) {
this.num = Preconditions.checkNotNull(num, "num");
return this;
}
/**
* Initializes the optional value {@link TDSavedQueryStartRequest#domainKey() domainKey} to domainKey.
* @param domainKey The value for domainKey
* @return {@code this} builder for chained invocation
*/
public final Builder domainKey(String domainKey) {
this.domainKey = Optional.of(domainKey);
return this;
}
/**
* Initializes the optional value {@link TDSavedQueryStartRequest#domainKey() domainKey} to domainKey.
* @param domainKey The value for domainKey
* @return {@code this} builder for use in a chained invocation
*/
public final Builder domainKey(Optional domainKey) {
this.domainKey = Preconditions.checkNotNull(domainKey, "domainKey");
return this;
}
/**
* Builds a new {@link ImmutableTDSavedQueryStartRequest ImmutableTDSavedQueryStartRequest}.
* @return An immutable instance of TDSavedQueryStartRequest
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableTDSavedQueryStartRequest build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableTDSavedQueryStartRequest(name, id, scheduledTime, num, domainKey);
}
private String formatRequiredAttributesMessage() {
List attributes = Lists.newArrayList();
if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name");
if ((initBits & INIT_BIT_SCHEDULED_TIME) != 0) attributes.add("scheduledTime");
return "Cannot build TDSavedQueryStartRequest, some of required attributes are not set " + attributes;
}
}
}