All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.pinpoint.model.SegmentDimensions Maven / Gradle / Ivy
Go to download
The AWS Java SDK for Amazon Pinpoint module holds the client classes that are used for communicating
with Amazon Pinpoint Service
/*
* Copyright 2014-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.pinpoint.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
* Segment dimensions
*/
@Generated("software.amazon.awssdk:codegen")
public final class SegmentDimensions implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField> ATTRIBUTES_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(SegmentDimensions::attributes))
.setter(setter(Builder::attributes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Attributes").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AttributeDimension::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField BEHAVIOR_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(SegmentDimensions::behavior))
.setter(setter(Builder::behavior)).constructor(SegmentBehaviors::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Behavior").build()).build();
private static final SdkField DEMOGRAPHIC_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(SegmentDimensions::demographic))
.setter(setter(Builder::demographic)).constructor(SegmentDemographics::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Demographic").build()).build();
private static final SdkField LOCATION_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.getter(getter(SegmentDimensions::location)).setter(setter(Builder::location)).constructor(SegmentLocation::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Location").build()).build();
private static final SdkField> METRICS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(SegmentDimensions::metrics))
.setter(setter(Builder::metrics))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Metrics").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(MetricDimension::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField> USER_ATTRIBUTES_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(SegmentDimensions::userAttributes))
.setter(setter(Builder::userAttributes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UserAttributes").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AttributeDimension::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ATTRIBUTES_FIELD,
BEHAVIOR_FIELD, DEMOGRAPHIC_FIELD, LOCATION_FIELD, METRICS_FIELD, USER_ATTRIBUTES_FIELD));
private static final long serialVersionUID = 1L;
private final Map attributes;
private final SegmentBehaviors behavior;
private final SegmentDemographics demographic;
private final SegmentLocation location;
private final Map metrics;
private final Map userAttributes;
private SegmentDimensions(BuilderImpl builder) {
this.attributes = builder.attributes;
this.behavior = builder.behavior;
this.demographic = builder.demographic;
this.location = builder.location;
this.metrics = builder.metrics;
this.userAttributes = builder.userAttributes;
}
/**
* Custom segment attributes.
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Custom segment attributes.
*/
public Map attributes() {
return attributes;
}
/**
* The segment behaviors attributes.
*
* @return The segment behaviors attributes.
*/
public SegmentBehaviors behavior() {
return behavior;
}
/**
* The segment demographics attributes.
*
* @return The segment demographics attributes.
*/
public SegmentDemographics demographic() {
return demographic;
}
/**
* The segment location attributes.
*
* @return The segment location attributes.
*/
public SegmentLocation location() {
return location;
}
/**
* Custom segment metrics.
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Custom segment metrics.
*/
public Map metrics() {
return metrics;
}
/**
* Custom segment user attributes.
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Custom segment user attributes.
*/
public Map userAttributes() {
return userAttributes;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(attributes());
hashCode = 31 * hashCode + Objects.hashCode(behavior());
hashCode = 31 * hashCode + Objects.hashCode(demographic());
hashCode = 31 * hashCode + Objects.hashCode(location());
hashCode = 31 * hashCode + Objects.hashCode(metrics());
hashCode = 31 * hashCode + Objects.hashCode(userAttributes());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SegmentDimensions)) {
return false;
}
SegmentDimensions other = (SegmentDimensions) obj;
return Objects.equals(attributes(), other.attributes()) && Objects.equals(behavior(), other.behavior())
&& Objects.equals(demographic(), other.demographic()) && Objects.equals(location(), other.location())
&& Objects.equals(metrics(), other.metrics()) && Objects.equals(userAttributes(), other.userAttributes());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public String toString() {
return ToString.builder("SegmentDimensions").add("Attributes", attributes()).add("Behavior", behavior())
.add("Demographic", demographic()).add("Location", location()).add("Metrics", metrics())
.add("UserAttributes", userAttributes()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Attributes":
return Optional.ofNullable(clazz.cast(attributes()));
case "Behavior":
return Optional.ofNullable(clazz.cast(behavior()));
case "Demographic":
return Optional.ofNullable(clazz.cast(demographic()));
case "Location":
return Optional.ofNullable(clazz.cast(location()));
case "Metrics":
return Optional.ofNullable(clazz.cast(metrics()));
case "UserAttributes":
return Optional.ofNullable(clazz.cast(userAttributes()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((SegmentDimensions) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
* Custom segment attributes.
*
* @param attributes
* Custom segment attributes.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder attributes(Map attributes);
/**
* The segment behaviors attributes.
*
* @param behavior
* The segment behaviors attributes.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder behavior(SegmentBehaviors behavior);
/**
* The segment behaviors attributes. This is a convenience that creates an instance of the
* {@link SegmentBehaviors.Builder} avoiding the need to create one manually via
* {@link SegmentBehaviors#builder()}.
*
* When the {@link Consumer} completes, {@link SegmentBehaviors.Builder#build()} is called immediately and its
* result is passed to {@link #behavior(SegmentBehaviors)}.
*
* @param behavior
* a consumer that will call methods on {@link SegmentBehaviors.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #behavior(SegmentBehaviors)
*/
default Builder behavior(Consumer behavior) {
return behavior(SegmentBehaviors.builder().applyMutation(behavior).build());
}
/**
* The segment demographics attributes.
*
* @param demographic
* The segment demographics attributes.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder demographic(SegmentDemographics demographic);
/**
* The segment demographics attributes. This is a convenience that creates an instance of the
* {@link SegmentDemographics.Builder} avoiding the need to create one manually via
* {@link SegmentDemographics#builder()}.
*
* When the {@link Consumer} completes, {@link SegmentDemographics.Builder#build()} is called immediately and
* its result is passed to {@link #demographic(SegmentDemographics)}.
*
* @param demographic
* a consumer that will call methods on {@link SegmentDemographics.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #demographic(SegmentDemographics)
*/
default Builder demographic(Consumer demographic) {
return demographic(SegmentDemographics.builder().applyMutation(demographic).build());
}
/**
* The segment location attributes.
*
* @param location
* The segment location attributes.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder location(SegmentLocation location);
/**
* The segment location attributes. This is a convenience that creates an instance of the
* {@link SegmentLocation.Builder} avoiding the need to create one manually via
* {@link SegmentLocation#builder()}.
*
* When the {@link Consumer} completes, {@link SegmentLocation.Builder#build()} is called immediately and its
* result is passed to {@link #location(SegmentLocation)}.
*
* @param location
* a consumer that will call methods on {@link SegmentLocation.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #location(SegmentLocation)
*/
default Builder location(Consumer location) {
return location(SegmentLocation.builder().applyMutation(location).build());
}
/**
* Custom segment metrics.
*
* @param metrics
* Custom segment metrics.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder metrics(Map metrics);
/**
* Custom segment user attributes.
*
* @param userAttributes
* Custom segment user attributes.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder userAttributes(Map userAttributes);
}
static final class BuilderImpl implements Builder {
private Map attributes = DefaultSdkAutoConstructMap.getInstance();
private SegmentBehaviors behavior;
private SegmentDemographics demographic;
private SegmentLocation location;
private Map metrics = DefaultSdkAutoConstructMap.getInstance();
private Map userAttributes = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(SegmentDimensions model) {
attributes(model.attributes);
behavior(model.behavior);
demographic(model.demographic);
location(model.location);
metrics(model.metrics);
userAttributes(model.userAttributes);
}
public final Map getAttributes() {
return attributes != null ? CollectionUtils.mapValues(attributes, AttributeDimension::toBuilder) : null;
}
@Override
public final Builder attributes(Map attributes) {
this.attributes = MapOfAttributeDimensionCopier.copy(attributes);
return this;
}
public final void setAttributes(Map attributes) {
this.attributes = MapOfAttributeDimensionCopier.copyFromBuilder(attributes);
}
public final SegmentBehaviors.Builder getBehavior() {
return behavior != null ? behavior.toBuilder() : null;
}
@Override
public final Builder behavior(SegmentBehaviors behavior) {
this.behavior = behavior;
return this;
}
public final void setBehavior(SegmentBehaviors.BuilderImpl behavior) {
this.behavior = behavior != null ? behavior.build() : null;
}
public final SegmentDemographics.Builder getDemographic() {
return demographic != null ? demographic.toBuilder() : null;
}
@Override
public final Builder demographic(SegmentDemographics demographic) {
this.demographic = demographic;
return this;
}
public final void setDemographic(SegmentDemographics.BuilderImpl demographic) {
this.demographic = demographic != null ? demographic.build() : null;
}
public final SegmentLocation.Builder getLocation() {
return location != null ? location.toBuilder() : null;
}
@Override
public final Builder location(SegmentLocation location) {
this.location = location;
return this;
}
public final void setLocation(SegmentLocation.BuilderImpl location) {
this.location = location != null ? location.build() : null;
}
public final Map getMetrics() {
return metrics != null ? CollectionUtils.mapValues(metrics, MetricDimension::toBuilder) : null;
}
@Override
public final Builder metrics(Map metrics) {
this.metrics = MapOfMetricDimensionCopier.copy(metrics);
return this;
}
public final void setMetrics(Map metrics) {
this.metrics = MapOfMetricDimensionCopier.copyFromBuilder(metrics);
}
public final Map getUserAttributes() {
return userAttributes != null ? CollectionUtils.mapValues(userAttributes, AttributeDimension::toBuilder) : null;
}
@Override
public final Builder userAttributes(Map userAttributes) {
this.userAttributes = MapOfAttributeDimensionCopier.copy(userAttributes);
return this;
}
public final void setUserAttributes(Map userAttributes) {
this.userAttributes = MapOfAttributeDimensionCopier.copyFromBuilder(userAttributes);
}
@Override
public SegmentDimensions build() {
return new SegmentDimensions(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}