software.amazon.awssdk.services.athena.model.ColumnInfo Maven / Gradle / Ivy
Show all versions of athena 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.athena.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
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;
/**
*
* Information about the columns in a query execution result.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ColumnInfo implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField CATALOG_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CatalogName").getter(getter(ColumnInfo::catalogName)).setter(setter(Builder::catalogName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CatalogName").build()).build();
private static final SdkField SCHEMA_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SchemaName").getter(getter(ColumnInfo::schemaName)).setter(setter(Builder::schemaName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SchemaName").build()).build();
private static final SdkField TABLE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TableName").getter(getter(ColumnInfo::tableName)).setter(setter(Builder::tableName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TableName").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(ColumnInfo::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField LABEL_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Label")
.getter(getter(ColumnInfo::label)).setter(setter(Builder::label))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Label").build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Type")
.getter(getter(ColumnInfo::type)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type").build()).build();
private static final SdkField PRECISION_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Precision").getter(getter(ColumnInfo::precision)).setter(setter(Builder::precision))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Precision").build()).build();
private static final SdkField SCALE_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("Scale")
.getter(getter(ColumnInfo::scale)).setter(setter(Builder::scale))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Scale").build()).build();
private static final SdkField NULLABLE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Nullable").getter(getter(ColumnInfo::nullableAsString)).setter(setter(Builder::nullable))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Nullable").build()).build();
private static final SdkField CASE_SENSITIVE_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("CaseSensitive").getter(getter(ColumnInfo::caseSensitive)).setter(setter(Builder::caseSensitive))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CaseSensitive").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CATALOG_NAME_FIELD,
SCHEMA_NAME_FIELD, TABLE_NAME_FIELD, NAME_FIELD, LABEL_FIELD, TYPE_FIELD, PRECISION_FIELD, SCALE_FIELD,
NULLABLE_FIELD, CASE_SENSITIVE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("CatalogName", CATALOG_NAME_FIELD);
put("SchemaName", SCHEMA_NAME_FIELD);
put("TableName", TABLE_NAME_FIELD);
put("Name", NAME_FIELD);
put("Label", LABEL_FIELD);
put("Type", TYPE_FIELD);
put("Precision", PRECISION_FIELD);
put("Scale", SCALE_FIELD);
put("Nullable", NULLABLE_FIELD);
put("CaseSensitive", CASE_SENSITIVE_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String catalogName;
private final String schemaName;
private final String tableName;
private final String name;
private final String label;
private final String type;
private final Integer precision;
private final Integer scale;
private final String nullable;
private final Boolean caseSensitive;
private ColumnInfo(BuilderImpl builder) {
this.catalogName = builder.catalogName;
this.schemaName = builder.schemaName;
this.tableName = builder.tableName;
this.name = builder.name;
this.label = builder.label;
this.type = builder.type;
this.precision = builder.precision;
this.scale = builder.scale;
this.nullable = builder.nullable;
this.caseSensitive = builder.caseSensitive;
}
/**
*
* The catalog to which the query results belong.
*
*
* @return The catalog to which the query results belong.
*/
public final String catalogName() {
return catalogName;
}
/**
*
* The schema name (database name) to which the query results belong.
*
*
* @return The schema name (database name) to which the query results belong.
*/
public final String schemaName() {
return schemaName;
}
/**
*
* The table name for the query results.
*
*
* @return The table name for the query results.
*/
public final String tableName() {
return tableName;
}
/**
*
* The name of the column.
*
*
* @return The name of the column.
*/
public final String name() {
return name;
}
/**
*
* A column label.
*
*
* @return A column label.
*/
public final String label() {
return label;
}
/**
*
* The data type of the column.
*
*
* @return The data type of the column.
*/
public final String type() {
return type;
}
/**
*
* For DECIMAL
data types, specifies the total number of digits, up to 38. For performance reasons, we
* recommend up to 18 digits.
*
*
* @return For DECIMAL
data types, specifies the total number of digits, up to 38. For performance
* reasons, we recommend up to 18 digits.
*/
public final Integer precision() {
return precision;
}
/**
*
* For DECIMAL
data types, specifies the total number of digits in the fractional part of the value.
* Defaults to 0.
*
*
* @return For DECIMAL
data types, specifies the total number of digits in the fractional part of the
* value. Defaults to 0.
*/
public final Integer scale() {
return scale;
}
/**
*
* Unsupported constraint. This value always shows as UNKNOWN
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #nullable} will
* return {@link ColumnNullable#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #nullableAsString}.
*
*
* @return Unsupported constraint. This value always shows as UNKNOWN
.
* @see ColumnNullable
*/
public final ColumnNullable nullable() {
return ColumnNullable.fromValue(nullable);
}
/**
*
* Unsupported constraint. This value always shows as UNKNOWN
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #nullable} will
* return {@link ColumnNullable#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #nullableAsString}.
*
*
* @return Unsupported constraint. This value always shows as UNKNOWN
.
* @see ColumnNullable
*/
public final String nullableAsString() {
return nullable;
}
/**
*
* Indicates whether values in the column are case-sensitive.
*
*
* @return Indicates whether values in the column are case-sensitive.
*/
public final Boolean caseSensitive() {
return caseSensitive;
}
@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(catalogName());
hashCode = 31 * hashCode + Objects.hashCode(schemaName());
hashCode = 31 * hashCode + Objects.hashCode(tableName());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(label());
hashCode = 31 * hashCode + Objects.hashCode(type());
hashCode = 31 * hashCode + Objects.hashCode(precision());
hashCode = 31 * hashCode + Objects.hashCode(scale());
hashCode = 31 * hashCode + Objects.hashCode(nullableAsString());
hashCode = 31 * hashCode + Objects.hashCode(caseSensitive());
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 ColumnInfo)) {
return false;
}
ColumnInfo other = (ColumnInfo) obj;
return Objects.equals(catalogName(), other.catalogName()) && Objects.equals(schemaName(), other.schemaName())
&& Objects.equals(tableName(), other.tableName()) && Objects.equals(name(), other.name())
&& Objects.equals(label(), other.label()) && Objects.equals(type(), other.type())
&& Objects.equals(precision(), other.precision()) && Objects.equals(scale(), other.scale())
&& Objects.equals(nullableAsString(), other.nullableAsString())
&& Objects.equals(caseSensitive(), other.caseSensitive());
}
/**
* 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("ColumnInfo").add("CatalogName", catalogName()).add("SchemaName", schemaName())
.add("TableName", tableName()).add("Name", name()).add("Label", label()).add("Type", type())
.add("Precision", precision()).add("Scale", scale()).add("Nullable", nullableAsString())
.add("CaseSensitive", caseSensitive()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "CatalogName":
return Optional.ofNullable(clazz.cast(catalogName()));
case "SchemaName":
return Optional.ofNullable(clazz.cast(schemaName()));
case "TableName":
return Optional.ofNullable(clazz.cast(tableName()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Label":
return Optional.ofNullable(clazz.cast(label()));
case "Type":
return Optional.ofNullable(clazz.cast(type()));
case "Precision":
return Optional.ofNullable(clazz.cast(precision()));
case "Scale":
return Optional.ofNullable(clazz.cast(scale()));
case "Nullable":
return Optional.ofNullable(clazz.cast(nullableAsString()));
case "CaseSensitive":
return Optional.ofNullable(clazz.cast(caseSensitive()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function