
software.amazon.awssdk.services.translate.model.TextTranslationJobProperties 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.translate.model;
import java.beans.Transient;
import java.io.Serializable;
import java.time.Instant;
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 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;
/**
*
* Provides information about a translation job.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TextTranslationJobProperties implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField JOB_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("JobId")
.getter(getter(TextTranslationJobProperties::jobId)).setter(setter(Builder::jobId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("JobId").build()).build();
private static final SdkField JOB_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("JobName").getter(getter(TextTranslationJobProperties::jobName)).setter(setter(Builder::jobName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("JobName").build()).build();
private static final SdkField JOB_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("JobStatus").getter(getter(TextTranslationJobProperties::jobStatusAsString))
.setter(setter(Builder::jobStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("JobStatus").build()).build();
private static final SdkField JOB_DETAILS_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("JobDetails").getter(getter(TextTranslationJobProperties::jobDetails))
.setter(setter(Builder::jobDetails)).constructor(JobDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("JobDetails").build()).build();
private static final SdkField SOURCE_LANGUAGE_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SourceLanguageCode").getter(getter(TextTranslationJobProperties::sourceLanguageCode))
.setter(setter(Builder::sourceLanguageCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceLanguageCode").build())
.build();
private static final SdkField> TARGET_LANGUAGE_CODES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("TargetLanguageCodes")
.getter(getter(TextTranslationJobProperties::targetLanguageCodes))
.setter(setter(Builder::targetLanguageCodes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetLanguageCodes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> TERMINOLOGY_NAMES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("TerminologyNames")
.getter(getter(TextTranslationJobProperties::terminologyNames))
.setter(setter(Builder::terminologyNames))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TerminologyNames").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> PARALLEL_DATA_NAMES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ParallelDataNames")
.getter(getter(TextTranslationJobProperties::parallelDataNames))
.setter(setter(Builder::parallelDataNames))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ParallelDataNames").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField MESSAGE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Message")
.getter(getter(TextTranslationJobProperties::message)).setter(setter(Builder::message))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Message").build()).build();
private static final SdkField SUBMITTED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("SubmittedTime").getter(getter(TextTranslationJobProperties::submittedTime))
.setter(setter(Builder::submittedTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubmittedTime").build()).build();
private static final SdkField END_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("EndTime").getter(getter(TextTranslationJobProperties::endTime)).setter(setter(Builder::endTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndTime").build()).build();
private static final SdkField INPUT_DATA_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("InputDataConfig")
.getter(getter(TextTranslationJobProperties::inputDataConfig)).setter(setter(Builder::inputDataConfig))
.constructor(InputDataConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InputDataConfig").build()).build();
private static final SdkField OUTPUT_DATA_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("OutputDataConfig")
.getter(getter(TextTranslationJobProperties::outputDataConfig)).setter(setter(Builder::outputDataConfig))
.constructor(OutputDataConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OutputDataConfig").build()).build();
private static final SdkField DATA_ACCESS_ROLE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DataAccessRoleArn").getter(getter(TextTranslationJobProperties::dataAccessRoleArn))
.setter(setter(Builder::dataAccessRoleArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DataAccessRoleArn").build()).build();
private static final SdkField SETTINGS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Settings")
.getter(getter(TextTranslationJobProperties::settings)).setter(setter(Builder::settings))
.constructor(TranslationSettings::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Settings").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(JOB_ID_FIELD, JOB_NAME_FIELD,
JOB_STATUS_FIELD, JOB_DETAILS_FIELD, SOURCE_LANGUAGE_CODE_FIELD, TARGET_LANGUAGE_CODES_FIELD,
TERMINOLOGY_NAMES_FIELD, PARALLEL_DATA_NAMES_FIELD, MESSAGE_FIELD, SUBMITTED_TIME_FIELD, END_TIME_FIELD,
INPUT_DATA_CONFIG_FIELD, OUTPUT_DATA_CONFIG_FIELD, DATA_ACCESS_ROLE_ARN_FIELD, SETTINGS_FIELD));
private static final long serialVersionUID = 1L;
private final String jobId;
private final String jobName;
private final String jobStatus;
private final JobDetails jobDetails;
private final String sourceLanguageCode;
private final List targetLanguageCodes;
private final List terminologyNames;
private final List parallelDataNames;
private final String message;
private final Instant submittedTime;
private final Instant endTime;
private final InputDataConfig inputDataConfig;
private final OutputDataConfig outputDataConfig;
private final String dataAccessRoleArn;
private final TranslationSettings settings;
private TextTranslationJobProperties(BuilderImpl builder) {
this.jobId = builder.jobId;
this.jobName = builder.jobName;
this.jobStatus = builder.jobStatus;
this.jobDetails = builder.jobDetails;
this.sourceLanguageCode = builder.sourceLanguageCode;
this.targetLanguageCodes = builder.targetLanguageCodes;
this.terminologyNames = builder.terminologyNames;
this.parallelDataNames = builder.parallelDataNames;
this.message = builder.message;
this.submittedTime = builder.submittedTime;
this.endTime = builder.endTime;
this.inputDataConfig = builder.inputDataConfig;
this.outputDataConfig = builder.outputDataConfig;
this.dataAccessRoleArn = builder.dataAccessRoleArn;
this.settings = builder.settings;
}
/**
*
* The ID of the translation job.
*
*
* @return The ID of the translation job.
*/
public final String jobId() {
return jobId;
}
/**
*
* The user-defined name of the translation job.
*
*
* @return The user-defined name of the translation job.
*/
public final String jobName() {
return jobName;
}
/**
*
* The status of the translation job.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #jobStatus} will
* return {@link JobStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #jobStatusAsString}.
*
*
* @return The status of the translation job.
* @see JobStatus
*/
public final JobStatus jobStatus() {
return JobStatus.fromValue(jobStatus);
}
/**
*
* The status of the translation job.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #jobStatus} will
* return {@link JobStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #jobStatusAsString}.
*
*
* @return The status of the translation job.
* @see JobStatus
*/
public final String jobStatusAsString() {
return jobStatus;
}
/**
*
* The number of documents successfully and unsuccessfully processed during the translation job.
*
*
* @return The number of documents successfully and unsuccessfully processed during the translation job.
*/
public final JobDetails jobDetails() {
return jobDetails;
}
/**
*
* The language code of the language of the source text. The language must be a language supported by Amazon
* Translate.
*
*
* @return The language code of the language of the source text. The language must be a language supported by Amazon
* Translate.
*/
public final String sourceLanguageCode() {
return sourceLanguageCode;
}
/**
* For responses, this returns true if the service returned a value for the TargetLanguageCodes property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasTargetLanguageCodes() {
return targetLanguageCodes != null && !(targetLanguageCodes instanceof SdkAutoConstructList);
}
/**
*
* The language code of the language of the target text. The language must be a language supported by Amazon
* Translate.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasTargetLanguageCodes} method.
*
*
* @return The language code of the language of the target text. The language must be a language supported by Amazon
* Translate.
*/
public final List targetLanguageCodes() {
return targetLanguageCodes;
}
/**
* For responses, this returns true if the service returned a value for the TerminologyNames property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasTerminologyNames() {
return terminologyNames != null && !(terminologyNames instanceof SdkAutoConstructList);
}
/**
*
* A list containing the names of the terminologies applied to a translation job. Only one terminology can be
* applied per StartTextTranslationJob request at this time.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasTerminologyNames} method.
*
*
* @return A list containing the names of the terminologies applied to a translation job. Only one terminology can
* be applied per StartTextTranslationJob request at this time.
*/
public final List terminologyNames() {
return terminologyNames;
}
/**
* For responses, this returns true if the service returned a value for the ParallelDataNames property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasParallelDataNames() {
return parallelDataNames != null && !(parallelDataNames instanceof SdkAutoConstructList);
}
/**
*
* A list containing the names of the parallel data resources applied to the translation job.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasParallelDataNames} method.
*
*
* @return A list containing the names of the parallel data resources applied to the translation job.
*/
public final List parallelDataNames() {
return parallelDataNames;
}
/**
*
* An explanation of any errors that may have occurred during the translation job.
*
*
* @return An explanation of any errors that may have occurred during the translation job.
*/
public final String message() {
return message;
}
/**
*
* The time at which the translation job was submitted.
*
*
* @return The time at which the translation job was submitted.
*/
public final Instant submittedTime() {
return submittedTime;
}
/**
*
* The time at which the translation job ended.
*
*
* @return The time at which the translation job ended.
*/
public final Instant endTime() {
return endTime;
}
/**
*
* The input configuration properties that were specified when the job was requested.
*
*
* @return The input configuration properties that were specified when the job was requested.
*/
public final InputDataConfig inputDataConfig() {
return inputDataConfig;
}
/**
*
* The output configuration properties that were specified when the job was requested.
*
*
* @return The output configuration properties that were specified when the job was requested.
*/
public final OutputDataConfig outputDataConfig() {
return outputDataConfig;
}
/**
*
* The Amazon Resource Name (ARN) of an AWS Identity Access and Management (IAM) role that granted Amazon Translate
* read access to the job's input data.
*
*
* @return The Amazon Resource Name (ARN) of an AWS Identity Access and Management (IAM) role that granted Amazon
* Translate read access to the job's input data.
*/
public final String dataAccessRoleArn() {
return dataAccessRoleArn;
}
/**
*
* Settings that modify the translation output.
*
*
* @return Settings that modify the translation output.
*/
public final TranslationSettings settings() {
return settings;
}
@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(jobId());
hashCode = 31 * hashCode + Objects.hashCode(jobName());
hashCode = 31 * hashCode + Objects.hashCode(jobStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(jobDetails());
hashCode = 31 * hashCode + Objects.hashCode(sourceLanguageCode());
hashCode = 31 * hashCode + Objects.hashCode(hasTargetLanguageCodes() ? targetLanguageCodes() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasTerminologyNames() ? terminologyNames() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasParallelDataNames() ? parallelDataNames() : null);
hashCode = 31 * hashCode + Objects.hashCode(message());
hashCode = 31 * hashCode + Objects.hashCode(submittedTime());
hashCode = 31 * hashCode + Objects.hashCode(endTime());
hashCode = 31 * hashCode + Objects.hashCode(inputDataConfig());
hashCode = 31 * hashCode + Objects.hashCode(outputDataConfig());
hashCode = 31 * hashCode + Objects.hashCode(dataAccessRoleArn());
hashCode = 31 * hashCode + Objects.hashCode(settings());
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 TextTranslationJobProperties)) {
return false;
}
TextTranslationJobProperties other = (TextTranslationJobProperties) obj;
return Objects.equals(jobId(), other.jobId()) && Objects.equals(jobName(), other.jobName())
&& Objects.equals(jobStatusAsString(), other.jobStatusAsString())
&& Objects.equals(jobDetails(), other.jobDetails())
&& Objects.equals(sourceLanguageCode(), other.sourceLanguageCode())
&& hasTargetLanguageCodes() == other.hasTargetLanguageCodes()
&& Objects.equals(targetLanguageCodes(), other.targetLanguageCodes())
&& hasTerminologyNames() == other.hasTerminologyNames()
&& Objects.equals(terminologyNames(), other.terminologyNames())
&& hasParallelDataNames() == other.hasParallelDataNames()
&& Objects.equals(parallelDataNames(), other.parallelDataNames()) && Objects.equals(message(), other.message())
&& Objects.equals(submittedTime(), other.submittedTime()) && Objects.equals(endTime(), other.endTime())
&& Objects.equals(inputDataConfig(), other.inputDataConfig())
&& Objects.equals(outputDataConfig(), other.outputDataConfig())
&& Objects.equals(dataAccessRoleArn(), other.dataAccessRoleArn()) && Objects.equals(settings(), other.settings());
}
/**
* 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("TextTranslationJobProperties").add("JobId", jobId()).add("JobName", jobName())
.add("JobStatus", jobStatusAsString()).add("JobDetails", jobDetails())
.add("SourceLanguageCode", sourceLanguageCode())
.add("TargetLanguageCodes", hasTargetLanguageCodes() ? targetLanguageCodes() : null)
.add("TerminologyNames", hasTerminologyNames() ? terminologyNames() : null)
.add("ParallelDataNames", hasParallelDataNames() ? parallelDataNames() : null).add("Message", message())
.add("SubmittedTime", submittedTime()).add("EndTime", endTime()).add("InputDataConfig", inputDataConfig())
.add("OutputDataConfig", outputDataConfig()).add("DataAccessRoleArn", dataAccessRoleArn())
.add("Settings", settings()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "JobId":
return Optional.ofNullable(clazz.cast(jobId()));
case "JobName":
return Optional.ofNullable(clazz.cast(jobName()));
case "JobStatus":
return Optional.ofNullable(clazz.cast(jobStatusAsString()));
case "JobDetails":
return Optional.ofNullable(clazz.cast(jobDetails()));
case "SourceLanguageCode":
return Optional.ofNullable(clazz.cast(sourceLanguageCode()));
case "TargetLanguageCodes":
return Optional.ofNullable(clazz.cast(targetLanguageCodes()));
case "TerminologyNames":
return Optional.ofNullable(clazz.cast(terminologyNames()));
case "ParallelDataNames":
return Optional.ofNullable(clazz.cast(parallelDataNames()));
case "Message":
return Optional.ofNullable(clazz.cast(message()));
case "SubmittedTime":
return Optional.ofNullable(clazz.cast(submittedTime()));
case "EndTime":
return Optional.ofNullable(clazz.cast(endTime()));
case "InputDataConfig":
return Optional.ofNullable(clazz.cast(inputDataConfig()));
case "OutputDataConfig":
return Optional.ofNullable(clazz.cast(outputDataConfig()));
case "DataAccessRoleArn":
return Optional.ofNullable(clazz.cast(dataAccessRoleArn()));
case "Settings":
return Optional.ofNullable(clazz.cast(settings()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function