![JAR search and dependency download from the Maven repository](/logo.png)
software.amazon.awssdk.services.timestreamwrite.model.DataModel Maven / Gradle / Ivy
/*
* 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.timestreamwrite.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;
/**
*
* Data model for a batch load task.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DataModel implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField TIME_COLUMN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TimeColumn").getter(getter(DataModel::timeColumn)).setter(setter(Builder::timeColumn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimeColumn").build()).build();
private static final SdkField TIME_UNIT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TimeUnit").getter(getter(DataModel::timeUnitAsString)).setter(setter(Builder::timeUnit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimeUnit").build()).build();
private static final SdkField> DIMENSION_MAPPINGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("DimensionMappings")
.getter(getter(DataModel::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(DataModel::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(DataModel::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(DataModel::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(TIME_COLUMN_FIELD,
TIME_UNIT_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 timeColumn;
private final String timeUnit;
private final List dimensionMappings;
private final MultiMeasureMappings multiMeasureMappings;
private final List mixedMeasureMappings;
private final String measureNameColumn;
private DataModel(BuilderImpl builder) {
this.timeColumn = builder.timeColumn;
this.timeUnit = builder.timeUnit;
this.dimensionMappings = builder.dimensionMappings;
this.multiMeasureMappings = builder.multiMeasureMappings;
this.mixedMeasureMappings = builder.mixedMeasureMappings;
this.measureNameColumn = builder.measureNameColumn;
}
/**
*
* Source column to be mapped to time.
*
*
* @return Source column to be mapped to time.
*/
public final String timeColumn() {
return timeColumn;
}
/**
*
* The granularity of the timestamp unit. It indicates if the time value is in seconds, milliseconds, nanoseconds,
* or other supported values. Default is MILLISECONDS
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #timeUnit} will
* return {@link TimeUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #timeUnitAsString}.
*
*
* @return The granularity of the timestamp unit. It indicates if the time value is in seconds, milliseconds,
* nanoseconds, or other supported values. Default is MILLISECONDS
.
* @see TimeUnit
*/
public final TimeUnit timeUnit() {
return TimeUnit.fromValue(timeUnit);
}
/**
*
* The granularity of the timestamp unit. It indicates if the time value is in seconds, milliseconds, nanoseconds,
* or other supported values. Default is MILLISECONDS
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #timeUnit} will
* return {@link TimeUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #timeUnitAsString}.
*
*
* @return The granularity of the timestamp unit. It indicates if the time value is in seconds, milliseconds,
* nanoseconds, or other supported values. Default is MILLISECONDS
.
* @see TimeUnit
*/
public final String timeUnitAsString() {
return timeUnit;
}
/**
* 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);
}
/**
*
* Source to target mappings for dimensions.
*
*
* 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 Source to target mappings for dimensions.
*/
public final List dimensionMappings() {
return dimensionMappings;
}
/**
*
* Source to target mappings for multi-measure records.
*
*
* @return Source to target mappings for multi-measure records.
*/
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);
}
/**
*
* Source to target mappings for 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 #hasMixedMeasureMappings} method.
*
*
* @return Source to target mappings for measures.
*/
public final List mixedMeasureMappings() {
return mixedMeasureMappings;
}
/**
*
*
* @return
*/
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(timeColumn());
hashCode = 31 * hashCode + Objects.hashCode(timeUnitAsString());
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 DataModel)) {
return false;
}
DataModel other = (DataModel) obj;
return Objects.equals(timeColumn(), other.timeColumn()) && Objects.equals(timeUnitAsString(), other.timeUnitAsString())
&& 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("DataModel").add("TimeColumn", timeColumn()).add("TimeUnit", timeUnitAsString())
.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 "TimeColumn":
return Optional.ofNullable(clazz.cast(timeColumn()));
case "TimeUnit":
return Optional.ofNullable(clazz.cast(timeUnitAsString()));
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