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

software.amazon.awssdk.services.timestreamquery.model.MixedMeasureMapping Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Timestream Query module holds the client classes that are used for communicating with Timestream Query.

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.timestreamquery.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* MixedMeasureMappings are mappings that can be used to ingest data into a mixture of narrow and multi measures in the * derived table. *

*/ @Generated("software.amazon.awssdk:codegen") public final class MixedMeasureMapping implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField MEASURE_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("MeasureName").getter(getter(MixedMeasureMapping::measureName)).setter(setter(Builder::measureName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MeasureName").build()).build(); private static final SdkField SOURCE_COLUMN_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("SourceColumn").getter(getter(MixedMeasureMapping::sourceColumn)).setter(setter(Builder::sourceColumn)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceColumn").build()).build(); private static final SdkField TARGET_MEASURE_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("TargetMeasureName").getter(getter(MixedMeasureMapping::targetMeasureName)) .setter(setter(Builder::targetMeasureName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetMeasureName").build()).build(); private static final SdkField MEASURE_VALUE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("MeasureValueType").getter(getter(MixedMeasureMapping::measureValueTypeAsString)) .setter(setter(Builder::measureValueType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MeasureValueType").build()).build(); private static final SdkField> MULTI_MEASURE_ATTRIBUTE_MAPPINGS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("MultiMeasureAttributeMappings") .getter(getter(MixedMeasureMapping::multiMeasureAttributeMappings)) .setter(setter(Builder::multiMeasureAttributeMappings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MultiMeasureAttributeMappings") .build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(MultiMeasureAttributeMapping::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(MEASURE_NAME_FIELD, SOURCE_COLUMN_FIELD, TARGET_MEASURE_NAME_FIELD, MEASURE_VALUE_TYPE_FIELD, MULTI_MEASURE_ATTRIBUTE_MAPPINGS_FIELD)); private static final long serialVersionUID = 1L; private final String measureName; private final String sourceColumn; private final String targetMeasureName; private final String measureValueType; private final List multiMeasureAttributeMappings; private MixedMeasureMapping(BuilderImpl builder) { this.measureName = builder.measureName; this.sourceColumn = builder.sourceColumn; this.targetMeasureName = builder.targetMeasureName; this.measureValueType = builder.measureValueType; this.multiMeasureAttributeMappings = builder.multiMeasureAttributeMappings; } /** *

* Refers to the value of measure_name in a result row. This field is required if MeasureNameColumn is provided. *

* * @return Refers to the value of measure_name in a result row. This field is required if MeasureNameColumn is * provided. */ public final String measureName() { return measureName; } /** *

* This field refers to the source column from which measure-value is to be read for result materialization. *

* * @return This field refers to the source column from which measure-value is to be read for result materialization. */ public final String sourceColumn() { return sourceColumn; } /** *

* Target measure name to be used. If not provided, the target measure name by default would be measure-name if * provided, or sourceColumn otherwise. *

* * @return Target measure name to be used. If not provided, the target measure name by default would be measure-name * if provided, or sourceColumn otherwise. */ public final String targetMeasureName() { return targetMeasureName; } /** *

* Type of the value that is to be read from sourceColumn. If the mapping is for MULTI, use MeasureValueType.MULTI. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #measureValueType} * will return {@link MeasureValueType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available * from {@link #measureValueTypeAsString}. *

* * @return Type of the value that is to be read from sourceColumn. If the mapping is for MULTI, use * MeasureValueType.MULTI. * @see MeasureValueType */ public final MeasureValueType measureValueType() { return MeasureValueType.fromValue(measureValueType); } /** *

* Type of the value that is to be read from sourceColumn. If the mapping is for MULTI, use MeasureValueType.MULTI. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #measureValueType} * will return {@link MeasureValueType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available * from {@link #measureValueTypeAsString}. *

* * @return Type of the value that is to be read from sourceColumn. If the mapping is for MULTI, use * MeasureValueType.MULTI. * @see MeasureValueType */ public final String measureValueTypeAsString() { return measureValueType; } /** * For responses, this returns true if the service returned a value for the MultiMeasureAttributeMappings 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 hasMultiMeasureAttributeMappings() { return multiMeasureAttributeMappings != null && !(multiMeasureAttributeMappings instanceof SdkAutoConstructList); } /** *

* Required when measureValueType is MULTI. Attribute mappings for MULTI value measures. *

*

* 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 #hasMultiMeasureAttributeMappings} method. *

* * @return Required when measureValueType is MULTI. Attribute mappings for MULTI value measures. */ public final List multiMeasureAttributeMappings() { return multiMeasureAttributeMappings; } @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(measureName()); hashCode = 31 * hashCode + Objects.hashCode(sourceColumn()); hashCode = 31 * hashCode + Objects.hashCode(targetMeasureName()); hashCode = 31 * hashCode + Objects.hashCode(measureValueTypeAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasMultiMeasureAttributeMappings() ? multiMeasureAttributeMappings() : 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 MixedMeasureMapping)) { return false; } MixedMeasureMapping other = (MixedMeasureMapping) obj; return Objects.equals(measureName(), other.measureName()) && Objects.equals(sourceColumn(), other.sourceColumn()) && Objects.equals(targetMeasureName(), other.targetMeasureName()) && Objects.equals(measureValueTypeAsString(), other.measureValueTypeAsString()) && hasMultiMeasureAttributeMappings() == other.hasMultiMeasureAttributeMappings() && Objects.equals(multiMeasureAttributeMappings(), other.multiMeasureAttributeMappings()); } /** * 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("MixedMeasureMapping") .add("MeasureName", measureName()) .add("SourceColumn", sourceColumn()) .add("TargetMeasureName", targetMeasureName()) .add("MeasureValueType", measureValueTypeAsString()) .add("MultiMeasureAttributeMappings", hasMultiMeasureAttributeMappings() ? multiMeasureAttributeMappings() : null) .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "MeasureName": return Optional.ofNullable(clazz.cast(measureName())); case "SourceColumn": return Optional.ofNullable(clazz.cast(sourceColumn())); case "TargetMeasureName": return Optional.ofNullable(clazz.cast(targetMeasureName())); case "MeasureValueType": return Optional.ofNullable(clazz.cast(measureValueTypeAsString())); case "MultiMeasureAttributeMappings": return Optional.ofNullable(clazz.cast(multiMeasureAttributeMappings())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((MixedMeasureMapping) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Refers to the value of measure_name in a result row. This field is required if MeasureNameColumn is provided. *

* * @param measureName * Refers to the value of measure_name in a result row. This field is required if MeasureNameColumn is * provided. * @return Returns a reference to this object so that method calls can be chained together. */ Builder measureName(String measureName); /** *

* This field refers to the source column from which measure-value is to be read for result materialization. *

* * @param sourceColumn * This field refers to the source column from which measure-value is to be read for result * materialization. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sourceColumn(String sourceColumn); /** *

* Target measure name to be used. If not provided, the target measure name by default would be measure-name if * provided, or sourceColumn otherwise. *

* * @param targetMeasureName * Target measure name to be used. If not provided, the target measure name by default would be * measure-name if provided, or sourceColumn otherwise. * @return Returns a reference to this object so that method calls can be chained together. */ Builder targetMeasureName(String targetMeasureName); /** *

* Type of the value that is to be read from sourceColumn. If the mapping is for MULTI, use * MeasureValueType.MULTI. *

* * @param measureValueType * Type of the value that is to be read from sourceColumn. If the mapping is for MULTI, use * MeasureValueType.MULTI. * @see MeasureValueType * @return Returns a reference to this object so that method calls can be chained together. * @see MeasureValueType */ Builder measureValueType(String measureValueType); /** *

* Type of the value that is to be read from sourceColumn. If the mapping is for MULTI, use * MeasureValueType.MULTI. *

* * @param measureValueType * Type of the value that is to be read from sourceColumn. If the mapping is for MULTI, use * MeasureValueType.MULTI. * @see MeasureValueType * @return Returns a reference to this object so that method calls can be chained together. * @see MeasureValueType */ Builder measureValueType(MeasureValueType measureValueType); /** *

* Required when measureValueType is MULTI. Attribute mappings for MULTI value measures. *

* * @param multiMeasureAttributeMappings * Required when measureValueType is MULTI. Attribute mappings for MULTI value measures. * @return Returns a reference to this object so that method calls can be chained together. */ Builder multiMeasureAttributeMappings(Collection multiMeasureAttributeMappings); /** *

* Required when measureValueType is MULTI. Attribute mappings for MULTI value measures. *

* * @param multiMeasureAttributeMappings * Required when measureValueType is MULTI. Attribute mappings for MULTI value measures. * @return Returns a reference to this object so that method calls can be chained together. */ Builder multiMeasureAttributeMappings(MultiMeasureAttributeMapping... multiMeasureAttributeMappings); /** *

* Required when measureValueType is MULTI. Attribute mappings for MULTI value measures. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.timestreamquery.model.MultiMeasureAttributeMapping.Builder} avoiding * the need to create one manually via * {@link software.amazon.awssdk.services.timestreamquery.model.MultiMeasureAttributeMapping#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.timestreamquery.model.MultiMeasureAttributeMapping.Builder#build()} is * called immediately and its result is passed to {@link * #multiMeasureAttributeMappings(List)}. * * @param multiMeasureAttributeMappings * a consumer that will call methods on * {@link software.amazon.awssdk.services.timestreamquery.model.MultiMeasureAttributeMapping.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #multiMeasureAttributeMappings(java.util.Collection) */ Builder multiMeasureAttributeMappings(Consumer... multiMeasureAttributeMappings); } static final class BuilderImpl implements Builder { private String measureName; private String sourceColumn; private String targetMeasureName; private String measureValueType; private List multiMeasureAttributeMappings = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(MixedMeasureMapping model) { measureName(model.measureName); sourceColumn(model.sourceColumn); targetMeasureName(model.targetMeasureName); measureValueType(model.measureValueType); multiMeasureAttributeMappings(model.multiMeasureAttributeMappings); } public final String getMeasureName() { return measureName; } public final void setMeasureName(String measureName) { this.measureName = measureName; } @Override public final Builder measureName(String measureName) { this.measureName = measureName; return this; } public final String getSourceColumn() { return sourceColumn; } public final void setSourceColumn(String sourceColumn) { this.sourceColumn = sourceColumn; } @Override public final Builder sourceColumn(String sourceColumn) { this.sourceColumn = sourceColumn; return this; } public final String getTargetMeasureName() { return targetMeasureName; } public final void setTargetMeasureName(String targetMeasureName) { this.targetMeasureName = targetMeasureName; } @Override public final Builder targetMeasureName(String targetMeasureName) { this.targetMeasureName = targetMeasureName; return this; } public final String getMeasureValueType() { return measureValueType; } public final void setMeasureValueType(String measureValueType) { this.measureValueType = measureValueType; } @Override public final Builder measureValueType(String measureValueType) { this.measureValueType = measureValueType; return this; } @Override public final Builder measureValueType(MeasureValueType measureValueType) { this.measureValueType(measureValueType == null ? null : measureValueType.toString()); return this; } public final List getMultiMeasureAttributeMappings() { List result = MultiMeasureAttributeMappingListCopier .copyToBuilder(this.multiMeasureAttributeMappings); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setMultiMeasureAttributeMappings( Collection multiMeasureAttributeMappings) { this.multiMeasureAttributeMappings = MultiMeasureAttributeMappingListCopier .copyFromBuilder(multiMeasureAttributeMappings); } @Override public final Builder multiMeasureAttributeMappings(Collection multiMeasureAttributeMappings) { this.multiMeasureAttributeMappings = MultiMeasureAttributeMappingListCopier.copy(multiMeasureAttributeMappings); return this; } @Override @SafeVarargs public final Builder multiMeasureAttributeMappings(MultiMeasureAttributeMapping... multiMeasureAttributeMappings) { multiMeasureAttributeMappings(Arrays.asList(multiMeasureAttributeMappings)); return this; } @Override @SafeVarargs public final Builder multiMeasureAttributeMappings( Consumer... multiMeasureAttributeMappings) { multiMeasureAttributeMappings(Stream.of(multiMeasureAttributeMappings) .map(c -> MultiMeasureAttributeMapping.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } @Override public MixedMeasureMapping build() { return new MixedMeasureMapping(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy