
software.amazon.awssdk.services.athena.model.CalculationStatus 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;
/**
*
* Contains information about the status of a notebook calculation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CalculationStatus implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField SUBMISSION_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("SubmissionDateTime").getter(getter(CalculationStatus::submissionDateTime))
.setter(setter(Builder::submissionDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubmissionDateTime").build())
.build();
private static final SdkField COMPLETION_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CompletionDateTime").getter(getter(CalculationStatus::completionDateTime))
.setter(setter(Builder::completionDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CompletionDateTime").build())
.build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(CalculationStatus::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField STATE_CHANGE_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StateChangeReason").getter(getter(CalculationStatus::stateChangeReason))
.setter(setter(Builder::stateChangeReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StateChangeReason").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SUBMISSION_DATE_TIME_FIELD,
COMPLETION_DATE_TIME_FIELD, STATE_FIELD, STATE_CHANGE_REASON_FIELD));
private static final long serialVersionUID = 1L;
private final Instant submissionDateTime;
private final Instant completionDateTime;
private final String state;
private final String stateChangeReason;
private CalculationStatus(BuilderImpl builder) {
this.submissionDateTime = builder.submissionDateTime;
this.completionDateTime = builder.completionDateTime;
this.state = builder.state;
this.stateChangeReason = builder.stateChangeReason;
}
/**
*
* The date and time the calculation was submitted for processing.
*
*
* @return The date and time the calculation was submitted for processing.
*/
public final Instant submissionDateTime() {
return submissionDateTime;
}
/**
*
* The date and time the calculation completed processing.
*
*
* @return The date and time the calculation completed processing.
*/
public final Instant completionDateTime() {
return completionDateTime;
}
/**
*
* The state of the calculation execution. A description of each state follows.
*
*
* CREATING
- The calculation is in the process of being created.
*
*
* CREATED
- The calculation has been created and is ready to run.
*
*
* QUEUED
- The calculation has been queued for processing.
*
*
* RUNNING
- The calculation is running.
*
*
* CANCELING
- A request to cancel the calculation has been received and the system is working to stop
* it.
*
*
* CANCELED
- The calculation is no longer running as the result of a cancel request.
*
*
* COMPLETED
- The calculation has completed without error.
*
*
* FAILED
- The calculation failed and is no longer running.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link CalculationExecutionState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the calculation execution. A description of each state follows.
*
* CREATING
- The calculation is in the process of being created.
*
*
* CREATED
- The calculation has been created and is ready to run.
*
*
* QUEUED
- The calculation has been queued for processing.
*
*
* RUNNING
- The calculation is running.
*
*
* CANCELING
- A request to cancel the calculation has been received and the system is working
* to stop it.
*
*
* CANCELED
- The calculation is no longer running as the result of a cancel request.
*
*
* COMPLETED
- The calculation has completed without error.
*
*
* FAILED
- The calculation failed and is no longer running.
* @see CalculationExecutionState
*/
public final CalculationExecutionState state() {
return CalculationExecutionState.fromValue(state);
}
/**
*
* The state of the calculation execution. A description of each state follows.
*
*
* CREATING
- The calculation is in the process of being created.
*
*
* CREATED
- The calculation has been created and is ready to run.
*
*
* QUEUED
- The calculation has been queued for processing.
*
*
* RUNNING
- The calculation is running.
*
*
* CANCELING
- A request to cancel the calculation has been received and the system is working to stop
* it.
*
*
* CANCELED
- The calculation is no longer running as the result of a cancel request.
*
*
* COMPLETED
- The calculation has completed without error.
*
*
* FAILED
- The calculation failed and is no longer running.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link CalculationExecutionState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the calculation execution. A description of each state follows.
*
* CREATING
- The calculation is in the process of being created.
*
*
* CREATED
- The calculation has been created and is ready to run.
*
*
* QUEUED
- The calculation has been queued for processing.
*
*
* RUNNING
- The calculation is running.
*
*
* CANCELING
- A request to cancel the calculation has been received and the system is working
* to stop it.
*
*
* CANCELED
- The calculation is no longer running as the result of a cancel request.
*
*
* COMPLETED
- The calculation has completed without error.
*
*
* FAILED
- The calculation failed and is no longer running.
* @see CalculationExecutionState
*/
public final String stateAsString() {
return state;
}
/**
*
* The reason for the calculation state change (for example, the calculation was canceled because the session was
* terminated).
*
*
* @return The reason for the calculation state change (for example, the calculation was canceled because the
* session was terminated).
*/
public final String stateChangeReason() {
return stateChangeReason;
}
@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(submissionDateTime());
hashCode = 31 * hashCode + Objects.hashCode(completionDateTime());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateChangeReason());
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 CalculationStatus)) {
return false;
}
CalculationStatus other = (CalculationStatus) obj;
return Objects.equals(submissionDateTime(), other.submissionDateTime())
&& Objects.equals(completionDateTime(), other.completionDateTime())
&& Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(stateChangeReason(), other.stateChangeReason());
}
/**
* 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("CalculationStatus").add("SubmissionDateTime", submissionDateTime())
.add("CompletionDateTime", completionDateTime()).add("State", stateAsString())
.add("StateChangeReason", stateChangeReason()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "SubmissionDateTime":
return Optional.ofNullable(clazz.cast(submissionDateTime()));
case "CompletionDateTime":
return Optional.ofNullable(clazz.cast(completionDateTime()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "StateChangeReason":
return Optional.ofNullable(clazz.cast(stateChangeReason()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function