software.amazon.awssdk.services.timestreamquery.model.TimestreamConfiguration 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;
/**
*
* Configuration to write data into Timestream database and table. This configuration allows the user to map the query
* result select columns into the destination table columns.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TimestreamConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField DATABASE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DatabaseName").getter(getter(TimestreamConfiguration::databaseName))
.setter(setter(Builder::databaseName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DatabaseName").build()).build();
private static final SdkField TABLE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TableName").getter(getter(TimestreamConfiguration::tableName)).setter(setter(Builder::tableName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TableName").build()).build();
private static final SdkField TIME_COLUMN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TimeColumn").getter(getter(TimestreamConfiguration::timeColumn)).setter(setter(Builder::timeColumn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimeColumn").build()).build();
private static final SdkField> DIMENSION_MAPPINGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("DimensionMappings")
.getter(getter(TimestreamConfiguration::dimensionMappings))
.setter(setter(Builder::dimensionMappings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DimensionMappings").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(DimensionMapping::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField MULTI_MEASURE_MAPPINGS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("MultiMeasureMappings")
.getter(getter(TimestreamConfiguration::multiMeasureMappings)).setter(setter(Builder::multiMeasureMappings))
.constructor(MultiMeasureMappings::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MultiMeasureMappings").build())
.build();
private static final SdkField> MIXED_MEASURE_MAPPINGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("MixedMeasureMappings")
.getter(getter(TimestreamConfiguration::mixedMeasureMappings))
.setter(setter(Builder::mixedMeasureMappings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MixedMeasureMappings").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(MixedMeasureMapping::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField MEASURE_NAME_COLUMN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("MeasureNameColumn").getter(getter(TimestreamConfiguration::measureNameColumn))
.setter(setter(Builder::measureNameColumn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MeasureNameColumn").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DATABASE_NAME_FIELD,
TABLE_NAME_FIELD, TIME_COLUMN_FIELD, DIMENSION_MAPPINGS_FIELD, MULTI_MEASURE_MAPPINGS_FIELD,
MIXED_MEASURE_MAPPINGS_FIELD, MEASURE_NAME_COLUMN_FIELD));
private static final long serialVersionUID = 1L;
private final String databaseName;
private final String tableName;
private final String timeColumn;
private final List dimensionMappings;
private final MultiMeasureMappings multiMeasureMappings;
private final List mixedMeasureMappings;
private final String measureNameColumn;
private TimestreamConfiguration(BuilderImpl builder) {
this.databaseName = builder.databaseName;
this.tableName = builder.tableName;
this.timeColumn = builder.timeColumn;
this.dimensionMappings = builder.dimensionMappings;
this.multiMeasureMappings = builder.multiMeasureMappings;
this.mixedMeasureMappings = builder.mixedMeasureMappings;
this.measureNameColumn = builder.measureNameColumn;
}
/**
*
* Name of Timestream database to which the query result will be written.
*
*
* @return Name of Timestream database to which the query result will be written.
*/
public final String databaseName() {
return databaseName;
}
/**
*
* Name of Timestream table that the query result will be written to. The table should be within the same database
* that is provided in Timestream configuration.
*
*
* @return Name of Timestream table that the query result will be written to. The table should be within the same
* database that is provided in Timestream configuration.
*/
public final String tableName() {
return tableName;
}
/**
*
* Column from query result that should be used as the time column in destination table. Column type for this should
* be TIMESTAMP.
*
*
* @return Column from query result that should be used as the time column in destination table. Column type for
* this should be TIMESTAMP.
*/
public final String timeColumn() {
return timeColumn;
}
/**
* For responses, this returns true if the service returned a value for the DimensionMappings 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 hasDimensionMappings() {
return dimensionMappings != null && !(dimensionMappings instanceof SdkAutoConstructList);
}
/**
*
* This is to allow mapping column(s) from the query result to the dimension in the destination table.
*
*
* 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 #hasDimensionMappings} method.
*
*
* @return This is to allow mapping column(s) from the query result to the dimension in the destination table.
*/
public final List dimensionMappings() {
return dimensionMappings;
}
/**
*
* Multi-measure mappings.
*
*
* @return Multi-measure mappings.
*/
public final MultiMeasureMappings multiMeasureMappings() {
return multiMeasureMappings;
}
/**
* For responses, this returns true if the service returned a value for the MixedMeasureMappings 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 hasMixedMeasureMappings() {
return mixedMeasureMappings != null && !(mixedMeasureMappings instanceof SdkAutoConstructList);
}
/**
*
* Specifies how to map measures to multi-measure records.
*
*
* 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 #hasMixedMeasureMappings} method.
*
*
* @return Specifies how to map measures to multi-measure records.
*/
public final List mixedMeasureMappings() {
return mixedMeasureMappings;
}
/**
*
* Name of the measure column.
*
*
* @return Name of the measure column.
*/
public final String measureNameColumn() {
return measureNameColumn;
}
@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(databaseName());
hashCode = 31 * hashCode + Objects.hashCode(tableName());
hashCode = 31 * hashCode + Objects.hashCode(timeColumn());
hashCode = 31 * hashCode + Objects.hashCode(hasDimensionMappings() ? dimensionMappings() : null);
hashCode = 31 * hashCode + Objects.hashCode(multiMeasureMappings());
hashCode = 31 * hashCode + Objects.hashCode(hasMixedMeasureMappings() ? mixedMeasureMappings() : null);
hashCode = 31 * hashCode + Objects.hashCode(measureNameColumn());
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 TimestreamConfiguration)) {
return false;
}
TimestreamConfiguration other = (TimestreamConfiguration) obj;
return Objects.equals(databaseName(), other.databaseName()) && Objects.equals(tableName(), other.tableName())
&& Objects.equals(timeColumn(), other.timeColumn()) && hasDimensionMappings() == other.hasDimensionMappings()
&& Objects.equals(dimensionMappings(), other.dimensionMappings())
&& Objects.equals(multiMeasureMappings(), other.multiMeasureMappings())
&& hasMixedMeasureMappings() == other.hasMixedMeasureMappings()
&& Objects.equals(mixedMeasureMappings(), other.mixedMeasureMappings())
&& Objects.equals(measureNameColumn(), other.measureNameColumn());
}
/**
* 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("TimestreamConfiguration").add("DatabaseName", databaseName()).add("TableName", tableName())
.add("TimeColumn", timeColumn()).add("DimensionMappings", hasDimensionMappings() ? dimensionMappings() : null)
.add("MultiMeasureMappings", multiMeasureMappings())
.add("MixedMeasureMappings", hasMixedMeasureMappings() ? mixedMeasureMappings() : null)
.add("MeasureNameColumn", measureNameColumn()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "DatabaseName":
return Optional.ofNullable(clazz.cast(databaseName()));
case "TableName":
return Optional.ofNullable(clazz.cast(tableName()));
case "TimeColumn":
return Optional.ofNullable(clazz.cast(timeColumn()));
case "DimensionMappings":
return Optional.ofNullable(clazz.cast(dimensionMappings()));
case "MultiMeasureMappings":
return Optional.ofNullable(clazz.cast(multiMeasureMappings()));
case "MixedMeasureMappings":
return Optional.ofNullable(clazz.cast(mixedMeasureMappings()));
case "MeasureNameColumn":
return Optional.ofNullable(clazz.cast(measureNameColumn()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function