software.amazon.awssdk.services.athena.model.PreparedStatement 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.athena.model;
import java.io.Serializable;
import java.time.Instant;
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.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 prepared SQL statement for use with Athena.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PreparedStatement implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField STATEMENT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StatementName").getter(getter(PreparedStatement::statementName)).setter(setter(Builder::statementName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatementName").build()).build();
private static final SdkField QUERY_STATEMENT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("QueryStatement").getter(getter(PreparedStatement::queryStatement))
.setter(setter(Builder::queryStatement))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryStatement").build()).build();
private static final SdkField WORK_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("WorkGroupName").getter(getter(PreparedStatement::workGroupName)).setter(setter(Builder::workGroupName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WorkGroupName").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(PreparedStatement::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField LAST_MODIFIED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastModifiedTime").getter(getter(PreparedStatement::lastModifiedTime))
.setter(setter(Builder::lastModifiedTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastModifiedTime").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STATEMENT_NAME_FIELD,
QUERY_STATEMENT_FIELD, WORK_GROUP_NAME_FIELD, DESCRIPTION_FIELD, LAST_MODIFIED_TIME_FIELD));
private static final long serialVersionUID = 1L;
private final String statementName;
private final String queryStatement;
private final String workGroupName;
private final String description;
private final Instant lastModifiedTime;
private PreparedStatement(BuilderImpl builder) {
this.statementName = builder.statementName;
this.queryStatement = builder.queryStatement;
this.workGroupName = builder.workGroupName;
this.description = builder.description;
this.lastModifiedTime = builder.lastModifiedTime;
}
/**
*
* The name of the prepared statement.
*
*
* @return The name of the prepared statement.
*/
public final String statementName() {
return statementName;
}
/**
*
* The query string for the prepared statement.
*
*
* @return The query string for the prepared statement.
*/
public final String queryStatement() {
return queryStatement;
}
/**
*
* The name of the workgroup to which the prepared statement belongs.
*
*
* @return The name of the workgroup to which the prepared statement belongs.
*/
public final String workGroupName() {
return workGroupName;
}
/**
*
* The description of the prepared statement.
*
*
* @return The description of the prepared statement.
*/
public final String description() {
return description;
}
/**
*
* The last modified time of the prepared statement.
*
*
* @return The last modified time of the prepared statement.
*/
public final Instant lastModifiedTime() {
return lastModifiedTime;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(statementName());
hashCode = 31 * hashCode + Objects.hashCode(queryStatement());
hashCode = 31 * hashCode + Objects.hashCode(workGroupName());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(lastModifiedTime());
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 PreparedStatement)) {
return false;
}
PreparedStatement other = (PreparedStatement) obj;
return Objects.equals(statementName(), other.statementName()) && Objects.equals(queryStatement(), other.queryStatement())
&& Objects.equals(workGroupName(), other.workGroupName()) && Objects.equals(description(), other.description())
&& Objects.equals(lastModifiedTime(), other.lastModifiedTime());
}
/**
* 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("PreparedStatement").add("StatementName", statementName())
.add("QueryStatement", queryStatement()).add("WorkGroupName", workGroupName()).add("Description", description())
.add("LastModifiedTime", lastModifiedTime()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "StatementName":
return Optional.ofNullable(clazz.cast(statementName()));
case "QueryStatement":
return Optional.ofNullable(clazz.cast(queryStatement()));
case "WorkGroupName":
return Optional.ofNullable(clazz.cast(workGroupName()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "LastModifiedTime":
return Optional.ofNullable(clazz.cast(lastModifiedTime()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function