
software.amazon.awssdk.services.swf.model.PollForDecisionTaskResponse 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.swf.model;
import java.util.Arrays;
import java.util.Collection;
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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A structure that represents a decision task. Decision tasks are sent to deciders in order for them to make decisions.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PollForDecisionTaskResponse extends SwfResponse implements
ToCopyableBuilder {
private static final SdkField TASK_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(PollForDecisionTaskResponse::taskToken)).setter(setter(Builder::taskToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("taskToken").build()).build();
private static final SdkField STARTED_EVENT_ID_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(PollForDecisionTaskResponse::startedEventId)).setter(setter(Builder::startedEventId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("startedEventId").build()).build();
private static final SdkField WORKFLOW_EXECUTION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(PollForDecisionTaskResponse::workflowExecution))
.setter(setter(Builder::workflowExecution)).constructor(WorkflowExecution::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("workflowExecution").build()).build();
private static final SdkField WORKFLOW_TYPE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.getter(getter(PollForDecisionTaskResponse::workflowType)).setter(setter(Builder::workflowType))
.constructor(WorkflowType::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("workflowType").build()).build();
private static final SdkField> EVENTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(PollForDecisionTaskResponse::events))
.setter(setter(Builder::events))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("events").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(HistoryEvent::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField NEXT_PAGE_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(PollForDecisionTaskResponse::nextPageToken)).setter(setter(Builder::nextPageToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("nextPageToken").build()).build();
private static final SdkField PREVIOUS_STARTED_EVENT_ID_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(PollForDecisionTaskResponse::previousStartedEventId)).setter(setter(Builder::previousStartedEventId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("previousStartedEventId").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TASK_TOKEN_FIELD,
STARTED_EVENT_ID_FIELD, WORKFLOW_EXECUTION_FIELD, WORKFLOW_TYPE_FIELD, EVENTS_FIELD, NEXT_PAGE_TOKEN_FIELD,
PREVIOUS_STARTED_EVENT_ID_FIELD));
private final String taskToken;
private final Long startedEventId;
private final WorkflowExecution workflowExecution;
private final WorkflowType workflowType;
private final List events;
private final String nextPageToken;
private final Long previousStartedEventId;
private PollForDecisionTaskResponse(BuilderImpl builder) {
super(builder);
this.taskToken = builder.taskToken;
this.startedEventId = builder.startedEventId;
this.workflowExecution = builder.workflowExecution;
this.workflowType = builder.workflowType;
this.events = builder.events;
this.nextPageToken = builder.nextPageToken;
this.previousStartedEventId = builder.previousStartedEventId;
}
/**
*
* The opaque string used as a handle on the task. This token is used by workers to communicate progress and
* response information back to the system about the task.
*
*
* @return The opaque string used as a handle on the task. This token is used by workers to communicate progress and
* response information back to the system about the task.
*/
public String taskToken() {
return taskToken;
}
/**
*
* The ID of the DecisionTaskStarted
event recorded in the history.
*
*
* @return The ID of the DecisionTaskStarted
event recorded in the history.
*/
public Long startedEventId() {
return startedEventId;
}
/**
*
* The workflow execution for which this decision task was created.
*
*
* @return The workflow execution for which this decision task was created.
*/
public WorkflowExecution workflowExecution() {
return workflowExecution;
}
/**
*
* The type of the workflow execution for which this decision task was created.
*
*
* @return The type of the workflow execution for which this decision task was created.
*/
public WorkflowType workflowType() {
return workflowType;
}
/**
* Returns true if the Events property was specified by the sender (it may be empty), or false if the sender did not
* specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public boolean hasEvents() {
return events != null && !(events instanceof SdkAutoConstructList);
}
/**
*
* A paginated list of history events of the workflow execution. The decider uses this during the processing of the
* decision task.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasEvents()} to see if a value was sent in this field.
*
*
* @return A paginated list of history events of the workflow execution. The decider uses this during the processing
* of the decision task.
*/
public List events() {
return events;
}
/**
*
* If a NextPageToken
was returned by a previous call, there are more results available. To retrieve
* the next page of results, make the call again using the returned token in nextPageToken
. Keep all
* other arguments unchanged.
*
*
* The configured maximumPageSize
determines how many results can be returned in a single call.
*
*
* @return If a NextPageToken
was returned by a previous call, there are more results available. To
* retrieve the next page of results, make the call again using the returned token in
* nextPageToken
. Keep all other arguments unchanged.
*
* The configured maximumPageSize
determines how many results can be returned in a single call.
*/
public String nextPageToken() {
return nextPageToken;
}
/**
*
* The ID of the DecisionTaskStarted event of the previous decision task of this workflow execution that was
* processed by the decider. This can be used to determine the events in the history new since the last decision
* task received by the decider.
*
*
* @return The ID of the DecisionTaskStarted event of the previous decision task of this workflow execution that was
* processed by the decider. This can be used to determine the events in the history new since the last
* decision task received by the decider.
*/
public Long previousStartedEventId() {
return previousStartedEventId;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(taskToken());
hashCode = 31 * hashCode + Objects.hashCode(startedEventId());
hashCode = 31 * hashCode + Objects.hashCode(workflowExecution());
hashCode = 31 * hashCode + Objects.hashCode(workflowType());
hashCode = 31 * hashCode + Objects.hashCode(events());
hashCode = 31 * hashCode + Objects.hashCode(nextPageToken());
hashCode = 31 * hashCode + Objects.hashCode(previousStartedEventId());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof PollForDecisionTaskResponse)) {
return false;
}
PollForDecisionTaskResponse other = (PollForDecisionTaskResponse) obj;
return Objects.equals(taskToken(), other.taskToken()) && Objects.equals(startedEventId(), other.startedEventId())
&& Objects.equals(workflowExecution(), other.workflowExecution())
&& Objects.equals(workflowType(), other.workflowType()) && Objects.equals(events(), other.events())
&& Objects.equals(nextPageToken(), other.nextPageToken())
&& Objects.equals(previousStartedEventId(), other.previousStartedEventId());
}
/**
* 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 String toString() {
return ToString.builder("PollForDecisionTaskResponse").add("TaskToken", taskToken())
.add("StartedEventId", startedEventId()).add("WorkflowExecution", workflowExecution())
.add("WorkflowType", workflowType()).add("Events", events()).add("NextPageToken", nextPageToken())
.add("PreviousStartedEventId", previousStartedEventId()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "taskToken":
return Optional.ofNullable(clazz.cast(taskToken()));
case "startedEventId":
return Optional.ofNullable(clazz.cast(startedEventId()));
case "workflowExecution":
return Optional.ofNullable(clazz.cast(workflowExecution()));
case "workflowType":
return Optional.ofNullable(clazz.cast(workflowType()));
case "events":
return Optional.ofNullable(clazz.cast(events()));
case "nextPageToken":
return Optional.ofNullable(clazz.cast(nextPageToken()));
case "previousStartedEventId":
return Optional.ofNullable(clazz.cast(previousStartedEventId()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function