com.myperfit.sdk.transactional.domain.tracking.TrackingGAnalyticsRequest Maven / Gradle / Ivy
Show all versions of transactionalsdk Show documentation
package com.myperfit.sdk.transactional.domain.tracking;
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 java.util.Objects;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link AbstractTrackingGAnalyticsRequest}.
*
* Use the builder to create immutable instances:
* {@code TrackingGAnalyticsRequest.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Immutable
public final class TrackingGAnalyticsRequest
extends AbstractTrackingGAnalyticsRequest {
private final Boolean enable;
private final @Nullable String utmSource;
private final @Nullable String utmMedium;
private final @Nullable String utmCampaign;
private final @Nullable String utmContent;
private final @Nullable String utmTerm;
private TrackingGAnalyticsRequest(
@Nullable String utmSource,
@Nullable String utmMedium,
@Nullable String utmCampaign,
@Nullable String utmContent,
@Nullable String utmTerm) {
this.utmSource = utmSource;
this.utmMedium = utmMedium;
this.utmCampaign = utmCampaign;
this.utmContent = utmContent;
this.utmTerm = utmTerm;
this.enable = Objects.requireNonNull(super.enable(), "enable");
}
/**
* @return The computed-at-construction value of the {@code enable} attribute
*/
@JsonProperty("enable")
@Override
public Boolean enable() {
return enable;
}
/**
* @return The value of the {@code utmSource} attribute
*/
@JsonProperty("utm_source")
@Override
public @Nullable String utmSource() {
return utmSource;
}
/**
* @return The value of the {@code utmMedium} attribute
*/
@JsonProperty("utm_medium")
@Override
public @Nullable String utmMedium() {
return utmMedium;
}
/**
* @return The value of the {@code utmCampaign} attribute
*/
@JsonProperty("utm_campaign")
@Override
public @Nullable String utmCampaign() {
return utmCampaign;
}
/**
* @return The value of the {@code utmContent} attribute
*/
@JsonProperty("utm_content")
@Override
public @Nullable String utmContent() {
return utmContent;
}
/**
* @return The value of the {@code utmTerm} attribute
*/
@JsonProperty("utm_term")
@Override
public @Nullable String utmTerm() {
return utmTerm;
}
/**
* Copy the current immutable object by setting a value for the {@link AbstractTrackingGAnalyticsRequest#utmSource() utmSource} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for utmSource (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final TrackingGAnalyticsRequest withUtmSource(@Nullable String value) {
if (Objects.equals(this.utmSource, value)) return this;
return new TrackingGAnalyticsRequest(value, this.utmMedium, this.utmCampaign, this.utmContent, this.utmTerm);
}
/**
* Copy the current immutable object by setting a value for the {@link AbstractTrackingGAnalyticsRequest#utmMedium() utmMedium} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for utmMedium (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final TrackingGAnalyticsRequest withUtmMedium(@Nullable String value) {
if (Objects.equals(this.utmMedium, value)) return this;
return new TrackingGAnalyticsRequest(this.utmSource, value, this.utmCampaign, this.utmContent, this.utmTerm);
}
/**
* Copy the current immutable object by setting a value for the {@link AbstractTrackingGAnalyticsRequest#utmCampaign() utmCampaign} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for utmCampaign (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final TrackingGAnalyticsRequest withUtmCampaign(@Nullable String value) {
if (Objects.equals(this.utmCampaign, value)) return this;
return new TrackingGAnalyticsRequest(this.utmSource, this.utmMedium, value, this.utmContent, this.utmTerm);
}
/**
* Copy the current immutable object by setting a value for the {@link AbstractTrackingGAnalyticsRequest#utmContent() utmContent} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for utmContent (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final TrackingGAnalyticsRequest withUtmContent(@Nullable String value) {
if (Objects.equals(this.utmContent, value)) return this;
return new TrackingGAnalyticsRequest(this.utmSource, this.utmMedium, this.utmCampaign, value, this.utmTerm);
}
/**
* Copy the current immutable object by setting a value for the {@link AbstractTrackingGAnalyticsRequest#utmTerm() utmTerm} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for utmTerm (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final TrackingGAnalyticsRequest withUtmTerm(@Nullable String value) {
if (Objects.equals(this.utmTerm, value)) return this;
return new TrackingGAnalyticsRequest(this.utmSource, this.utmMedium, this.utmCampaign, this.utmContent, value);
}
/**
* This instance is equal to all instances of {@code TrackingGAnalyticsRequest} 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 TrackingGAnalyticsRequest
&& equalTo((TrackingGAnalyticsRequest) another);
}
private boolean equalTo(TrackingGAnalyticsRequest another) {
return enable.equals(another.enable)
&& Objects.equals(utmSource, another.utmSource)
&& Objects.equals(utmMedium, another.utmMedium)
&& Objects.equals(utmCampaign, another.utmCampaign)
&& Objects.equals(utmContent, another.utmContent)
&& Objects.equals(utmTerm, another.utmTerm);
}
/**
* Computes a hash code from attributes: {@code enable}, {@code utmSource}, {@code utmMedium}, {@code utmCampaign}, {@code utmContent}, {@code utmTerm}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + enable.hashCode();
h += (h << 5) + Objects.hashCode(utmSource);
h += (h << 5) + Objects.hashCode(utmMedium);
h += (h << 5) + Objects.hashCode(utmCampaign);
h += (h << 5) + Objects.hashCode(utmContent);
h += (h << 5) + Objects.hashCode(utmTerm);
return h;
}
/**
* Prints the immutable value {@code TrackingGAnalyticsRequest} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "TrackingGAnalyticsRequest{"
+ "enable=" + enable
+ ", utmSource=" + utmSource
+ ", utmMedium=" + utmMedium
+ ", utmCampaign=" + utmCampaign
+ ", utmContent=" + utmContent
+ ", utmTerm=" + utmTerm
+ "}";
}
/**
* 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 AbstractTrackingGAnalyticsRequest {
@Nullable String utmSource;
@Nullable String utmMedium;
@Nullable String utmCampaign;
@Nullable String utmContent;
@Nullable String utmTerm;
@JsonProperty("utm_source")
public void setUtmSource(@Nullable String utmSource) {
this.utmSource = utmSource;
}
@JsonProperty("utm_medium")
public void setUtmMedium(@Nullable String utmMedium) {
this.utmMedium = utmMedium;
}
@JsonProperty("utm_campaign")
public void setUtmCampaign(@Nullable String utmCampaign) {
this.utmCampaign = utmCampaign;
}
@JsonProperty("utm_content")
public void setUtmContent(@Nullable String utmContent) {
this.utmContent = utmContent;
}
@JsonProperty("utm_term")
public void setUtmTerm(@Nullable String utmTerm) {
this.utmTerm = utmTerm;
}
@Override
public Boolean enable() { throw new UnsupportedOperationException(); }
@Override
public String utmSource() { throw new UnsupportedOperationException(); }
@Override
public String utmMedium() { throw new UnsupportedOperationException(); }
@Override
public String utmCampaign() { throw new UnsupportedOperationException(); }
@Override
public String utmContent() { throw new UnsupportedOperationException(); }
@Override
public String utmTerm() { 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 TrackingGAnalyticsRequest fromJson(Json json) {
TrackingGAnalyticsRequest.Builder builder = TrackingGAnalyticsRequest.builder();
if (json.utmSource != null) {
builder.utmSource(json.utmSource);
}
if (json.utmMedium != null) {
builder.utmMedium(json.utmMedium);
}
if (json.utmCampaign != null) {
builder.utmCampaign(json.utmCampaign);
}
if (json.utmContent != null) {
builder.utmContent(json.utmContent);
}
if (json.utmTerm != null) {
builder.utmTerm(json.utmTerm);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link AbstractTrackingGAnalyticsRequest} 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 TrackingGAnalyticsRequest instance
*/
public static TrackingGAnalyticsRequest copyOf(AbstractTrackingGAnalyticsRequest instance) {
if (instance instanceof TrackingGAnalyticsRequest) {
return (TrackingGAnalyticsRequest) instance;
}
return TrackingGAnalyticsRequest.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link TrackingGAnalyticsRequest TrackingGAnalyticsRequest}.
* @return A new TrackingGAnalyticsRequest builder
*/
public static TrackingGAnalyticsRequest.Builder builder() {
return new TrackingGAnalyticsRequest.Builder();
}
/**
* Builds instances of type {@link TrackingGAnalyticsRequest TrackingGAnalyticsRequest}.
* 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
public static final class Builder {
private @Nullable String utmSource;
private @Nullable String utmMedium;
private @Nullable String utmCampaign;
private @Nullable String utmContent;
private @Nullable String utmTerm;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code AbstractTrackingGAnalyticsRequest} 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(AbstractTrackingGAnalyticsRequest instance) {
Objects.requireNonNull(instance, "instance");
@Nullable String utmSourceValue = instance.utmSource();
if (utmSourceValue != null) {
utmSource(utmSourceValue);
}
@Nullable String utmMediumValue = instance.utmMedium();
if (utmMediumValue != null) {
utmMedium(utmMediumValue);
}
@Nullable String utmCampaignValue = instance.utmCampaign();
if (utmCampaignValue != null) {
utmCampaign(utmCampaignValue);
}
@Nullable String utmContentValue = instance.utmContent();
if (utmContentValue != null) {
utmContent(utmContentValue);
}
@Nullable String utmTermValue = instance.utmTerm();
if (utmTermValue != null) {
utmTerm(utmTermValue);
}
return this;
}
/**
* Initializes the value for the {@link AbstractTrackingGAnalyticsRequest#utmSource() utmSource} attribute.
* @param utmSource The value for utmSource (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("utm_source")
public final Builder utmSource(@Nullable String utmSource) {
this.utmSource = utmSource;
return this;
}
/**
* Initializes the value for the {@link AbstractTrackingGAnalyticsRequest#utmMedium() utmMedium} attribute.
* @param utmMedium The value for utmMedium (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("utm_medium")
public final Builder utmMedium(@Nullable String utmMedium) {
this.utmMedium = utmMedium;
return this;
}
/**
* Initializes the value for the {@link AbstractTrackingGAnalyticsRequest#utmCampaign() utmCampaign} attribute.
* @param utmCampaign The value for utmCampaign (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("utm_campaign")
public final Builder utmCampaign(@Nullable String utmCampaign) {
this.utmCampaign = utmCampaign;
return this;
}
/**
* Initializes the value for the {@link AbstractTrackingGAnalyticsRequest#utmContent() utmContent} attribute.
* @param utmContent The value for utmContent (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("utm_content")
public final Builder utmContent(@Nullable String utmContent) {
this.utmContent = utmContent;
return this;
}
/**
* Initializes the value for the {@link AbstractTrackingGAnalyticsRequest#utmTerm() utmTerm} attribute.
* @param utmTerm The value for utmTerm (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("utm_term")
public final Builder utmTerm(@Nullable String utmTerm) {
this.utmTerm = utmTerm;
return this;
}
/**
* Builds a new {@link TrackingGAnalyticsRequest TrackingGAnalyticsRequest}.
* @return An immutable instance of TrackingGAnalyticsRequest
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public TrackingGAnalyticsRequest build() {
return new TrackingGAnalyticsRequest(utmSource, utmMedium, utmCampaign, utmContent, utmTerm);
}
}
}