software.amazon.awssdk.services.mturk.model.Assignment Maven / Gradle / Ivy
Show all versions of mturk 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.mturk.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;
/**
*
* The Assignment data structure represents a single assignment of a HIT to a Worker. The assignment tracks the Worker's
* efforts to complete the HIT, and contains the results for later retrieval.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Assignment implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ASSIGNMENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AssignmentId").getter(getter(Assignment::assignmentId)).setter(setter(Builder::assignmentId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssignmentId").build()).build();
private static final SdkField WORKER_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("WorkerId").getter(getter(Assignment::workerId)).setter(setter(Builder::workerId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WorkerId").build()).build();
private static final SdkField HIT_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("HITId")
.getter(getter(Assignment::hitId)).setter(setter(Builder::hitId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HITId").build()).build();
private static final SdkField ASSIGNMENT_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AssignmentStatus").getter(getter(Assignment::assignmentStatusAsString))
.setter(setter(Builder::assignmentStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssignmentStatus").build()).build();
private static final SdkField AUTO_APPROVAL_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("AutoApprovalTime").getter(getter(Assignment::autoApprovalTime))
.setter(setter(Builder::autoApprovalTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AutoApprovalTime").build()).build();
private static final SdkField ACCEPT_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("AcceptTime").getter(getter(Assignment::acceptTime)).setter(setter(Builder::acceptTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AcceptTime").build()).build();
private static final SdkField SUBMIT_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("SubmitTime").getter(getter(Assignment::submitTime)).setter(setter(Builder::submitTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubmitTime").build()).build();
private static final SdkField APPROVAL_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("ApprovalTime").getter(getter(Assignment::approvalTime)).setter(setter(Builder::approvalTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ApprovalTime").build()).build();
private static final SdkField REJECTION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("RejectionTime").getter(getter(Assignment::rejectionTime)).setter(setter(Builder::rejectionTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RejectionTime").build()).build();
private static final SdkField DEADLINE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("Deadline").getter(getter(Assignment::deadline)).setter(setter(Builder::deadline))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Deadline").build()).build();
private static final SdkField ANSWER_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Answer")
.getter(getter(Assignment::answer)).setter(setter(Builder::answer))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Answer").build()).build();
private static final SdkField REQUESTER_FEEDBACK_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RequesterFeedback").getter(getter(Assignment::requesterFeedback))
.setter(setter(Builder::requesterFeedback))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RequesterFeedback").build()).build();
private static final List> SDK_FIELDS = Collections
.unmodifiableList(Arrays.asList(ASSIGNMENT_ID_FIELD, WORKER_ID_FIELD, HIT_ID_FIELD, ASSIGNMENT_STATUS_FIELD,
AUTO_APPROVAL_TIME_FIELD, ACCEPT_TIME_FIELD, SUBMIT_TIME_FIELD, APPROVAL_TIME_FIELD, REJECTION_TIME_FIELD,
DEADLINE_FIELD, ANSWER_FIELD, REQUESTER_FEEDBACK_FIELD));
private static final long serialVersionUID = 1L;
private final String assignmentId;
private final String workerId;
private final String hitId;
private final String assignmentStatus;
private final Instant autoApprovalTime;
private final Instant acceptTime;
private final Instant submitTime;
private final Instant approvalTime;
private final Instant rejectionTime;
private final Instant deadline;
private final String answer;
private final String requesterFeedback;
private Assignment(BuilderImpl builder) {
this.assignmentId = builder.assignmentId;
this.workerId = builder.workerId;
this.hitId = builder.hitId;
this.assignmentStatus = builder.assignmentStatus;
this.autoApprovalTime = builder.autoApprovalTime;
this.acceptTime = builder.acceptTime;
this.submitTime = builder.submitTime;
this.approvalTime = builder.approvalTime;
this.rejectionTime = builder.rejectionTime;
this.deadline = builder.deadline;
this.answer = builder.answer;
this.requesterFeedback = builder.requesterFeedback;
}
/**
*
* A unique identifier for the assignment.
*
*
* @return A unique identifier for the assignment.
*/
public final String assignmentId() {
return assignmentId;
}
/**
*
* The ID of the Worker who accepted the HIT.
*
*
* @return The ID of the Worker who accepted the HIT.
*/
public final String workerId() {
return workerId;
}
/**
*
* The ID of the HIT.
*
*
* @return The ID of the HIT.
*/
public final String hitId() {
return hitId;
}
/**
*
* The status of the assignment.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #assignmentStatus}
* will return {@link AssignmentStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #assignmentStatusAsString}.
*
*
* @return The status of the assignment.
* @see AssignmentStatus
*/
public final AssignmentStatus assignmentStatus() {
return AssignmentStatus.fromValue(assignmentStatus);
}
/**
*
* The status of the assignment.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #assignmentStatus}
* will return {@link AssignmentStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #assignmentStatusAsString}.
*
*
* @return The status of the assignment.
* @see AssignmentStatus
*/
public final String assignmentStatusAsString() {
return assignmentStatus;
}
/**
*
* If results have been submitted, AutoApprovalTime is the date and time the results of the assignment results are
* considered Approved automatically if they have not already been explicitly approved or rejected by the Requester.
* This value is derived from the auto-approval delay specified by the Requester in the HIT. This value is omitted
* from the assignment if the Worker has not yet submitted results.
*
*
* @return If results have been submitted, AutoApprovalTime is the date and time the results of the assignment
* results are considered Approved automatically if they have not already been explicitly approved or
* rejected by the Requester. This value is derived from the auto-approval delay specified by the Requester
* in the HIT. This value is omitted from the assignment if the Worker has not yet submitted results.
*/
public final Instant autoApprovalTime() {
return autoApprovalTime;
}
/**
*
* The date and time the Worker accepted the assignment.
*
*
* @return The date and time the Worker accepted the assignment.
*/
public final Instant acceptTime() {
return acceptTime;
}
/**
*
* If the Worker has submitted results, SubmitTime is the date and time the assignment was submitted. This value is
* omitted from the assignment if the Worker has not yet submitted results.
*
*
* @return If the Worker has submitted results, SubmitTime is the date and time the assignment was submitted. This
* value is omitted from the assignment if the Worker has not yet submitted results.
*/
public final Instant submitTime() {
return submitTime;
}
/**
*
* If the Worker has submitted results and the Requester has approved the results, ApprovalTime is the date and time
* the Requester approved the results. This value is omitted from the assignment if the Requester has not yet
* approved the results.
*
*
* @return If the Worker has submitted results and the Requester has approved the results, ApprovalTime is the date
* and time the Requester approved the results. This value is omitted from the assignment if the Requester
* has not yet approved the results.
*/
public final Instant approvalTime() {
return approvalTime;
}
/**
*
* If the Worker has submitted results and the Requester has rejected the results, RejectionTime is the date and
* time the Requester rejected the results.
*
*
* @return If the Worker has submitted results and the Requester has rejected the results, RejectionTime is the date
* and time the Requester rejected the results.
*/
public final Instant rejectionTime() {
return rejectionTime;
}
/**
*
* The date and time of the deadline for the assignment. This value is derived from the deadline specification for
* the HIT and the date and time the Worker accepted the HIT.
*
*
* @return The date and time of the deadline for the assignment. This value is derived from the deadline
* specification for the HIT and the date and time the Worker accepted the HIT.
*/
public final Instant deadline() {
return deadline;
}
/**
*
* The Worker's answers submitted for the HIT contained in a QuestionFormAnswers document, if the Worker provides an
* answer. If the Worker does not provide any answers, Answer may contain a QuestionFormAnswers document, or Answer
* may be empty.
*
*
* @return The Worker's answers submitted for the HIT contained in a QuestionFormAnswers document, if the Worker
* provides an answer. If the Worker does not provide any answers, Answer may contain a QuestionFormAnswers
* document, or Answer may be empty.
*/
public final String answer() {
return answer;
}
/**
*
* The feedback string included with the call to the ApproveAssignment operation or the RejectAssignment operation,
* if the Requester approved or rejected the assignment and specified feedback.
*
*
* @return The feedback string included with the call to the ApproveAssignment operation or the RejectAssignment
* operation, if the Requester approved or rejected the assignment and specified feedback.
*/
public final String requesterFeedback() {
return requesterFeedback;
}
@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(assignmentId());
hashCode = 31 * hashCode + Objects.hashCode(workerId());
hashCode = 31 * hashCode + Objects.hashCode(hitId());
hashCode = 31 * hashCode + Objects.hashCode(assignmentStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(autoApprovalTime());
hashCode = 31 * hashCode + Objects.hashCode(acceptTime());
hashCode = 31 * hashCode + Objects.hashCode(submitTime());
hashCode = 31 * hashCode + Objects.hashCode(approvalTime());
hashCode = 31 * hashCode + Objects.hashCode(rejectionTime());
hashCode = 31 * hashCode + Objects.hashCode(deadline());
hashCode = 31 * hashCode + Objects.hashCode(answer());
hashCode = 31 * hashCode + Objects.hashCode(requesterFeedback());
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 Assignment)) {
return false;
}
Assignment other = (Assignment) obj;
return Objects.equals(assignmentId(), other.assignmentId()) && Objects.equals(workerId(), other.workerId())
&& Objects.equals(hitId(), other.hitId())
&& Objects.equals(assignmentStatusAsString(), other.assignmentStatusAsString())
&& Objects.equals(autoApprovalTime(), other.autoApprovalTime())
&& Objects.equals(acceptTime(), other.acceptTime()) && Objects.equals(submitTime(), other.submitTime())
&& Objects.equals(approvalTime(), other.approvalTime()) && Objects.equals(rejectionTime(), other.rejectionTime())
&& Objects.equals(deadline(), other.deadline()) && Objects.equals(answer(), other.answer())
&& Objects.equals(requesterFeedback(), other.requesterFeedback());
}
/**
* 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("Assignment").add("AssignmentId", assignmentId()).add("WorkerId", workerId())
.add("HITId", hitId()).add("AssignmentStatus", assignmentStatusAsString())
.add("AutoApprovalTime", autoApprovalTime()).add("AcceptTime", acceptTime()).add("SubmitTime", submitTime())
.add("ApprovalTime", approvalTime()).add("RejectionTime", rejectionTime()).add("Deadline", deadline())
.add("Answer", answer()).add("RequesterFeedback", requesterFeedback()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AssignmentId":
return Optional.ofNullable(clazz.cast(assignmentId()));
case "WorkerId":
return Optional.ofNullable(clazz.cast(workerId()));
case "HITId":
return Optional.ofNullable(clazz.cast(hitId()));
case "AssignmentStatus":
return Optional.ofNullable(clazz.cast(assignmentStatusAsString()));
case "AutoApprovalTime":
return Optional.ofNullable(clazz.cast(autoApprovalTime()));
case "AcceptTime":
return Optional.ofNullable(clazz.cast(acceptTime()));
case "SubmitTime":
return Optional.ofNullable(clazz.cast(submitTime()));
case "ApprovalTime":
return Optional.ofNullable(clazz.cast(approvalTime()));
case "RejectionTime":
return Optional.ofNullable(clazz.cast(rejectionTime()));
case "Deadline":
return Optional.ofNullable(clazz.cast(deadline()));
case "Answer":
return Optional.ofNullable(clazz.cast(answer()));
case "RequesterFeedback":
return Optional.ofNullable(clazz.cast(requesterFeedback()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function