software.amazon.awssdk.services.glue.model.ViewValidation Maven / Gradle / Ivy
Show all versions of glue 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.glue.model;
import java.io.Serializable;
import java.time.Instant;
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.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;
/**
*
* A structure that contains information for an analytical engine to validate a view, prior to persisting the view
* metadata. Used in the case of direct UpdateTable
or CreateTable
API calls.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ViewValidation implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField DIALECT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Dialect")
.getter(getter(ViewValidation::dialectAsString)).setter(setter(Builder::dialect))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Dialect").build()).build();
private static final SdkField DIALECT_VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DialectVersion").getter(getter(ViewValidation::dialectVersion)).setter(setter(Builder::dialectVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DialectVersion").build()).build();
private static final SdkField VIEW_VALIDATION_TEXT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ViewValidationText").getter(getter(ViewValidation::viewValidationText))
.setter(setter(Builder::viewValidationText))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ViewValidationText").build())
.build();
private static final SdkField UPDATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("UpdateTime").getter(getter(ViewValidation::updateTime)).setter(setter(Builder::updateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UpdateTime").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(ViewValidation::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField ERROR_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Error").getter(getter(ViewValidation::error)).setter(setter(Builder::error))
.constructor(ErrorDetail::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Error").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DIALECT_FIELD,
DIALECT_VERSION_FIELD, VIEW_VALIDATION_TEXT_FIELD, UPDATE_TIME_FIELD, STATE_FIELD, ERROR_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String dialect;
private final String dialectVersion;
private final String viewValidationText;
private final Instant updateTime;
private final String state;
private final ErrorDetail error;
private ViewValidation(BuilderImpl builder) {
this.dialect = builder.dialect;
this.dialectVersion = builder.dialectVersion;
this.viewValidationText = builder.viewValidationText;
this.updateTime = builder.updateTime;
this.state = builder.state;
this.error = builder.error;
}
/**
*
* The dialect of the query engine.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #dialect} will
* return {@link ViewDialect#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #dialectAsString}.
*
*
* @return The dialect of the query engine.
* @see ViewDialect
*/
public final ViewDialect dialect() {
return ViewDialect.fromValue(dialect);
}
/**
*
* The dialect of the query engine.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #dialect} will
* return {@link ViewDialect#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #dialectAsString}.
*
*
* @return The dialect of the query engine.
* @see ViewDialect
*/
public final String dialectAsString() {
return dialect;
}
/**
*
* The version of the dialect of the query engine. For example, 3.0.0.
*
*
* @return The version of the dialect of the query engine. For example, 3.0.0.
*/
public final String dialectVersion() {
return dialectVersion;
}
/**
*
* The SELECT
query that defines the view, as provided by the customer.
*
*
* @return The SELECT
query that defines the view, as provided by the customer.
*/
public final String viewValidationText() {
return viewValidationText;
}
/**
*
* The time of the last update.
*
*
* @return The time of the last update.
*/
public final Instant updateTime() {
return updateTime;
}
/**
*
* The state of the validation.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ResourceState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the validation.
* @see ResourceState
*/
public final ResourceState state() {
return ResourceState.fromValue(state);
}
/**
*
* The state of the validation.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ResourceState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the validation.
* @see ResourceState
*/
public final String stateAsString() {
return state;
}
/**
*
* An error associated with the validation.
*
*
* @return An error associated with the validation.
*/
public final ErrorDetail error() {
return error;
}
@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(dialectAsString());
hashCode = 31 * hashCode + Objects.hashCode(dialectVersion());
hashCode = 31 * hashCode + Objects.hashCode(viewValidationText());
hashCode = 31 * hashCode + Objects.hashCode(updateTime());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(error());
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 ViewValidation)) {
return false;
}
ViewValidation other = (ViewValidation) obj;
return Objects.equals(dialectAsString(), other.dialectAsString())
&& Objects.equals(dialectVersion(), other.dialectVersion())
&& Objects.equals(viewValidationText(), other.viewValidationText())
&& Objects.equals(updateTime(), other.updateTime()) && Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(error(), other.error());
}
/**
* 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("ViewValidation").add("Dialect", dialectAsString()).add("DialectVersion", dialectVersion())
.add("ViewValidationText", viewValidationText()).add("UpdateTime", updateTime()).add("State", stateAsString())
.add("Error", error()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Dialect":
return Optional.ofNullable(clazz.cast(dialectAsString()));
case "DialectVersion":
return Optional.ofNullable(clazz.cast(dialectVersion()));
case "ViewValidationText":
return Optional.ofNullable(clazz.cast(viewValidationText()));
case "UpdateTime":
return Optional.ofNullable(clazz.cast(updateTime()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "Error":
return Optional.ofNullable(clazz.cast(error()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("Dialect", DIALECT_FIELD);
map.put("DialectVersion", DIALECT_VERSION_FIELD);
map.put("ViewValidationText", VIEW_VALIDATION_TEXT_FIELD);
map.put("UpdateTime", UPDATE_TIME_FIELD);
map.put("State", STATE_FIELD);
map.put("Error", ERROR_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function