All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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

There is a newer version: 2.28.4
Show newest version
/*
 * Copyright 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.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Specifies the dimension settings for a segment. *

*/ @Generated("software.amazon.awssdk:codegen") public final class SegmentDimensions implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> ATTRIBUTES_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("Attributes") .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).memberName("Behavior") .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).memberName("Demographic") .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) .memberName("Location").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) .memberName("Metrics") .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) .memberName("UserAttributes") .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; } /** * For responses, this returns true if the service returned a value for the Attributes property. This DOES NOT check * that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is * useful because the SDK will never return a null collection or map, but you may need to differentiate between the * service returning nothing (or null) and the service returning an empty collection or map. For requests, this * returns true if a value for the property was specified in the request builder, and false if a value was not * specified. */ public final boolean hasAttributes() { return attributes != null && !(attributes instanceof SdkAutoConstructMap); } /** *

* One or more custom attributes to use as criteria for the segment. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasAttributes} method. *

* * @return One or more custom attributes to use as criteria for the segment. */ public final Map attributes() { return attributes; } /** *

* The behavior-based criteria, such as how recently users have used your app, for the segment. *

* * @return The behavior-based criteria, such as how recently users have used your app, for the segment. */ public final SegmentBehaviors behavior() { return behavior; } /** *

* The demographic-based criteria, such as device platform, for the segment. *

* * @return The demographic-based criteria, such as device platform, for the segment. */ public final SegmentDemographics demographic() { return demographic; } /** *

* The location-based criteria, such as region or GPS coordinates, for the segment. *

* * @return The location-based criteria, such as region or GPS coordinates, for the segment. */ public final SegmentLocation location() { return location; } /** * For responses, this returns true if the service returned a value for the Metrics property. This DOES NOT check * that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is * useful because the SDK will never return a null collection or map, but you may need to differentiate between the * service returning nothing (or null) and the service returning an empty collection or map. For requests, this * returns true if a value for the property was specified in the request builder, and false if a value was not * specified. */ public final boolean hasMetrics() { return metrics != null && !(metrics instanceof SdkAutoConstructMap); } /** *

* One or more custom metrics to use as criteria for the segment. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasMetrics} method. *

* * @return One or more custom metrics to use as criteria for the segment. */ public final Map metrics() { return metrics; } /** * For responses, this returns true if the service returned a value for the UserAttributes property. This DOES NOT * check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). * This is useful because the SDK will never return a null collection or map, but you may need to differentiate * between the service returning nothing (or null) and the service returning an empty collection or map. For * requests, this returns true if a value for the property was specified in the request builder, and false if a * value was not specified. */ public final boolean hasUserAttributes() { return userAttributes != null && !(userAttributes instanceof SdkAutoConstructMap); } /** *

* One or more custom user attributes to use as criteria for the segment. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasUserAttributes} method. *

* * @return One or more custom user attributes to use as criteria for the segment. */ public final Map userAttributes() { return userAttributes; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(hasAttributes() ? attributes() : null); hashCode = 31 * hashCode + Objects.hashCode(behavior()); hashCode = 31 * hashCode + Objects.hashCode(demographic()); hashCode = 31 * hashCode + Objects.hashCode(location()); hashCode = 31 * hashCode + Objects.hashCode(hasMetrics() ? metrics() : null); hashCode = 31 * hashCode + Objects.hashCode(hasUserAttributes() ? userAttributes() : null); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof SegmentDimensions)) { return false; } SegmentDimensions other = (SegmentDimensions) obj; return hasAttributes() == other.hasAttributes() && Objects.equals(attributes(), other.attributes()) && Objects.equals(behavior(), other.behavior()) && Objects.equals(demographic(), other.demographic()) && Objects.equals(location(), other.location()) && hasMetrics() == other.hasMetrics() && Objects.equals(metrics(), other.metrics()) && hasUserAttributes() == other.hasUserAttributes() && 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 final String toString() { return ToString.builder("SegmentDimensions").add("Attributes", hasAttributes() ? attributes() : null) .add("Behavior", behavior()).add("Demographic", demographic()).add("Location", location()) .add("Metrics", hasMetrics() ? metrics() : null) .add("UserAttributes", hasUserAttributes() ? userAttributes() : null).build(); } public final 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 final 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 { /** *

* One or more custom attributes to use as criteria for the segment. *

* * @param attributes * One or more custom attributes to use as criteria for the segment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attributes(Map attributes); /** *

* The behavior-based criteria, such as how recently users have used your app, for the segment. *

* * @param behavior * The behavior-based criteria, such as how recently users have used your app, for the segment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder behavior(SegmentBehaviors behavior); /** *

* The behavior-based criteria, such as how recently users have used your app, for the segment. *

* This is a convenience method 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 demographic-based criteria, such as device platform, for the segment. *

* * @param demographic * The demographic-based criteria, such as device platform, for the segment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder demographic(SegmentDemographics demographic); /** *

* The demographic-based criteria, such as device platform, for the segment. *

* This is a convenience method 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 location-based criteria, such as region or GPS coordinates, for the segment. *

* * @param location * The location-based criteria, such as region or GPS coordinates, for the segment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder location(SegmentLocation location); /** *

* The location-based criteria, such as region or GPS coordinates, for the segment. *

* This is a convenience method 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()); } /** *

* One or more custom metrics to use as criteria for the segment. *

* * @param metrics * One or more custom metrics to use as criteria for the segment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder metrics(Map metrics); /** *

* One or more custom user attributes to use as criteria for the segment. *

* * @param userAttributes * One or more custom user attributes to use as criteria for the segment. * @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() { Map result = MapOfAttributeDimensionCopier.copyToBuilder(this.attributes); if (result instanceof SdkAutoConstructMap) { return null; } return result; } public final void setAttributes(Map attributes) { this.attributes = MapOfAttributeDimensionCopier.copyFromBuilder(attributes); } @Override public final Builder attributes(Map attributes) { this.attributes = MapOfAttributeDimensionCopier.copy(attributes); return this; } public final SegmentBehaviors.Builder getBehavior() { return behavior != null ? behavior.toBuilder() : null; } public final void setBehavior(SegmentBehaviors.BuilderImpl behavior) { this.behavior = behavior != null ? behavior.build() : null; } @Override public final Builder behavior(SegmentBehaviors behavior) { this.behavior = behavior; return this; } public final SegmentDemographics.Builder getDemographic() { return demographic != null ? demographic.toBuilder() : null; } public final void setDemographic(SegmentDemographics.BuilderImpl demographic) { this.demographic = demographic != null ? demographic.build() : null; } @Override public final Builder demographic(SegmentDemographics demographic) { this.demographic = demographic; return this; } public final SegmentLocation.Builder getLocation() { return location != null ? location.toBuilder() : null; } public final void setLocation(SegmentLocation.BuilderImpl location) { this.location = location != null ? location.build() : null; } @Override public final Builder location(SegmentLocation location) { this.location = location; return this; } public final Map getMetrics() { Map result = MapOfMetricDimensionCopier.copyToBuilder(this.metrics); if (result instanceof SdkAutoConstructMap) { return null; } return result; } public final void setMetrics(Map metrics) { this.metrics = MapOfMetricDimensionCopier.copyFromBuilder(metrics); } @Override public final Builder metrics(Map metrics) { this.metrics = MapOfMetricDimensionCopier.copy(metrics); return this; } public final Map getUserAttributes() { Map result = MapOfAttributeDimensionCopier.copyToBuilder(this.userAttributes); if (result instanceof SdkAutoConstructMap) { return null; } return result; } public final void setUserAttributes(Map userAttributes) { this.userAttributes = MapOfAttributeDimensionCopier.copyFromBuilder(userAttributes); } @Override public final Builder userAttributes(Map userAttributes) { this.userAttributes = MapOfAttributeDimensionCopier.copy(userAttributes); return this; } @Override public SegmentDimensions build() { return new SegmentDimensions(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy