software.amazon.awssdk.services.timestreamquery.model.MixedMeasureMapping Maven / Gradle / Ivy
Show all versions of timestreamquery Show documentation
/*
* 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 extends Builder> 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