software.amazon.awssdk.services.swf.model.WorkflowExecutionTerminatedEventAttributes Maven / Gradle / Ivy
Show all versions of swf 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.swf.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;
/**
*
* Provides the details of the WorkflowExecutionTerminated
event.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class WorkflowExecutionTerminatedEventAttributes implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField REASON_FIELD = SdkField. builder(MarshallingType.STRING).memberName("reason")
.getter(getter(WorkflowExecutionTerminatedEventAttributes::reason)).setter(setter(Builder::reason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("reason").build()).build();
private static final SdkField DETAILS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("details")
.getter(getter(WorkflowExecutionTerminatedEventAttributes::details)).setter(setter(Builder::details))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("details").build()).build();
private static final SdkField CHILD_POLICY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("childPolicy").getter(getter(WorkflowExecutionTerminatedEventAttributes::childPolicyAsString))
.setter(setter(Builder::childPolicy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("childPolicy").build()).build();
private static final SdkField CAUSE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("cause")
.getter(getter(WorkflowExecutionTerminatedEventAttributes::causeAsString)).setter(setter(Builder::cause))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("cause").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(REASON_FIELD, DETAILS_FIELD,
CHILD_POLICY_FIELD, CAUSE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String reason;
private final String details;
private final String childPolicy;
private final String causeValue;
private WorkflowExecutionTerminatedEventAttributes(BuilderImpl builder) {
this.reason = builder.reason;
this.details = builder.details;
this.childPolicy = builder.childPolicy;
this.causeValue = builder.causeValue;
}
/**
*
* The reason provided for the termination.
*
*
* @return The reason provided for the termination.
*/
public final String reason() {
return reason;
}
/**
*
* The details provided for the termination.
*
*
* @return The details provided for the termination.
*/
public final String details() {
return details;
}
/**
*
* The policy used for the child workflow executions of this workflow execution.
*
*
* The supported child policies are:
*
*
* -
*
* TERMINATE
– The child executions are terminated.
*
*
* -
*
* REQUEST_CANCEL
– A request to cancel is attempted for each child execution by recording a
* WorkflowExecutionCancelRequested
event in its history. It is up to the decider to take appropriate
* actions when it receives an execution history with this event.
*
*
* -
*
* ABANDON
– No action is taken. The child executions continue to run.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #childPolicy} will
* return {@link ChildPolicy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #childPolicyAsString}.
*
*
* @return The policy used for the child workflow executions of this workflow execution.
*
* The supported child policies are:
*
*
* -
*
* TERMINATE
– The child executions are terminated.
*
*
* -
*
* REQUEST_CANCEL
– A request to cancel is attempted for each child execution by recording a
* WorkflowExecutionCancelRequested
event in its history. It is up to the decider to take
* appropriate actions when it receives an execution history with this event.
*
*
* -
*
* ABANDON
– No action is taken. The child executions continue to run.
*
*
* @see ChildPolicy
*/
public final ChildPolicy childPolicy() {
return ChildPolicy.fromValue(childPolicy);
}
/**
*
* The policy used for the child workflow executions of this workflow execution.
*
*
* The supported child policies are:
*
*
* -
*
* TERMINATE
– The child executions are terminated.
*
*
* -
*
* REQUEST_CANCEL
– A request to cancel is attempted for each child execution by recording a
* WorkflowExecutionCancelRequested
event in its history. It is up to the decider to take appropriate
* actions when it receives an execution history with this event.
*
*
* -
*
* ABANDON
– No action is taken. The child executions continue to run.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #childPolicy} will
* return {@link ChildPolicy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #childPolicyAsString}.
*
*
* @return The policy used for the child workflow executions of this workflow execution.
*
* The supported child policies are:
*
*
* -
*
* TERMINATE
– The child executions are terminated.
*
*
* -
*
* REQUEST_CANCEL
– A request to cancel is attempted for each child execution by recording a
* WorkflowExecutionCancelRequested
event in its history. It is up to the decider to take
* appropriate actions when it receives an execution history with this event.
*
*
* -
*
* ABANDON
– No action is taken. The child executions continue to run.
*
*
* @see ChildPolicy
*/
public final String childPolicyAsString() {
return childPolicy;
}
/**
*
* If set, indicates that the workflow execution was automatically terminated, and specifies the cause. This happens
* if the parent workflow execution times out or is terminated and the child policy is set to terminate child
* executions.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #cause} will return
* {@link WorkflowExecutionTerminatedCause#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #causeAsString}.
*
*
* @return If set, indicates that the workflow execution was automatically terminated, and specifies the cause. This
* happens if the parent workflow execution times out or is terminated and the child policy is set to
* terminate child executions.
* @see WorkflowExecutionTerminatedCause
*/
public final WorkflowExecutionTerminatedCause cause() {
return WorkflowExecutionTerminatedCause.fromValue(causeValue);
}
/**
*
* If set, indicates that the workflow execution was automatically terminated, and specifies the cause. This happens
* if the parent workflow execution times out or is terminated and the child policy is set to terminate child
* executions.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #cause} will return
* {@link WorkflowExecutionTerminatedCause#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #causeAsString}.
*
*
* @return If set, indicates that the workflow execution was automatically terminated, and specifies the cause. This
* happens if the parent workflow execution times out or is terminated and the child policy is set to
* terminate child executions.
* @see WorkflowExecutionTerminatedCause
*/
public final String causeAsString() {
return causeValue;
}
@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(reason());
hashCode = 31 * hashCode + Objects.hashCode(details());
hashCode = 31 * hashCode + Objects.hashCode(childPolicyAsString());
hashCode = 31 * hashCode + Objects.hashCode(causeAsString());
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 WorkflowExecutionTerminatedEventAttributes)) {
return false;
}
WorkflowExecutionTerminatedEventAttributes other = (WorkflowExecutionTerminatedEventAttributes) obj;
return Objects.equals(reason(), other.reason()) && Objects.equals(details(), other.details())
&& Objects.equals(childPolicyAsString(), other.childPolicyAsString())
&& Objects.equals(causeAsString(), other.causeAsString());
}
/**
* 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("WorkflowExecutionTerminatedEventAttributes").add("Reason", reason()).add("Details", details())
.add("ChildPolicy", childPolicyAsString()).add("Cause", causeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "reason":
return Optional.ofNullable(clazz.cast(reason()));
case "details":
return Optional.ofNullable(clazz.cast(details()));
case "childPolicy":
return Optional.ofNullable(clazz.cast(childPolicyAsString()));
case "cause":
return Optional.ofNullable(clazz.cast(causeAsString()));
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("reason", REASON_FIELD);
map.put("details", DETAILS_FIELD);
map.put("childPolicy", CHILD_POLICY_FIELD);
map.put("cause", CAUSE_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function