
software.amazon.awssdk.services.quicksight.model.DateMeasureField 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.quicksight.model;
import java.io.Serializable;
import java.util.Arrays;
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 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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The measure type field with date type columns.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DateMeasureField implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField FIELD_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("FieldId").getter(getter(DateMeasureField::fieldId)).setter(setter(Builder::fieldId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FieldId").build()).build();
private static final SdkField COLUMN_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Column").getter(getter(DateMeasureField::column)).setter(setter(Builder::column))
.constructor(ColumnIdentifier::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Column").build()).build();
private static final SdkField AGGREGATION_FUNCTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AggregationFunction").getter(getter(DateMeasureField::aggregationFunctionAsString))
.setter(setter(Builder::aggregationFunction))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AggregationFunction").build())
.build();
private static final SdkField FORMAT_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("FormatConfiguration")
.getter(getter(DateMeasureField::formatConfiguration)).setter(setter(Builder::formatConfiguration))
.constructor(DateTimeFormatConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FormatConfiguration").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FIELD_ID_FIELD, COLUMN_FIELD,
AGGREGATION_FUNCTION_FIELD, FORMAT_CONFIGURATION_FIELD));
private static final long serialVersionUID = 1L;
private final String fieldId;
private final ColumnIdentifier column;
private final String aggregationFunction;
private final DateTimeFormatConfiguration formatConfiguration;
private DateMeasureField(BuilderImpl builder) {
this.fieldId = builder.fieldId;
this.column = builder.column;
this.aggregationFunction = builder.aggregationFunction;
this.formatConfiguration = builder.formatConfiguration;
}
/**
*
* The custom field ID.
*
*
* @return The custom field ID.
*/
public final String fieldId() {
return fieldId;
}
/**
*
* The column that is used in the DateMeasureField
.
*
*
* @return The column that is used in the DateMeasureField
.
*/
public final ColumnIdentifier column() {
return column;
}
/**
*
* The aggregation function of the measure field.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #aggregationFunction} will return {@link DateAggregationFunction#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #aggregationFunctionAsString}.
*
*
* @return The aggregation function of the measure field.
* @see DateAggregationFunction
*/
public final DateAggregationFunction aggregationFunction() {
return DateAggregationFunction.fromValue(aggregationFunction);
}
/**
*
* The aggregation function of the measure field.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #aggregationFunction} will return {@link DateAggregationFunction#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #aggregationFunctionAsString}.
*
*
* @return The aggregation function of the measure field.
* @see DateAggregationFunction
*/
public final String aggregationFunctionAsString() {
return aggregationFunction;
}
/**
*
* The format configuration of the field.
*
*
* @return The format configuration of the field.
*/
public final DateTimeFormatConfiguration formatConfiguration() {
return formatConfiguration;
}
@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(fieldId());
hashCode = 31 * hashCode + Objects.hashCode(column());
hashCode = 31 * hashCode + Objects.hashCode(aggregationFunctionAsString());
hashCode = 31 * hashCode + Objects.hashCode(formatConfiguration());
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 DateMeasureField)) {
return false;
}
DateMeasureField other = (DateMeasureField) obj;
return Objects.equals(fieldId(), other.fieldId()) && Objects.equals(column(), other.column())
&& Objects.equals(aggregationFunctionAsString(), other.aggregationFunctionAsString())
&& Objects.equals(formatConfiguration(), other.formatConfiguration());
}
/**
* 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("DateMeasureField").add("FieldId", fieldId()).add("Column", column())
.add("AggregationFunction", aggregationFunctionAsString()).add("FormatConfiguration", formatConfiguration())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "FieldId":
return Optional.ofNullable(clazz.cast(fieldId()));
case "Column":
return Optional.ofNullable(clazz.cast(column()));
case "AggregationFunction":
return Optional.ofNullable(clazz.cast(aggregationFunctionAsString()));
case "FormatConfiguration":
return Optional.ofNullable(clazz.cast(formatConfiguration()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function