software.amazon.awssdk.services.transcribe.model.Subtitles Maven / Gradle / Ivy
Show all versions of transcribe 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.transcribe.model;
import java.io.Serializable;
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.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;
/**
*
* Generate subtitles for your media file with your transcription request.
*
*
* You can choose a start index of 0 or 1, and you can specify either WebVTT or SubRip (or both) as your output format.
*
*
* Note that your subtitle files are placed in the same location as your transcription output.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Subtitles implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField> FORMATS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Formats")
.getter(getter(Subtitles::formatsAsStrings))
.setter(setter(Builder::formatsWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Formats").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 OUTPUT_START_INDEX_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("OutputStartIndex").getter(getter(Subtitles::outputStartIndex)).setter(setter(Builder::outputStartIndex))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OutputStartIndex").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FORMATS_FIELD,
OUTPUT_START_INDEX_FIELD));
private static final long serialVersionUID = 1L;
private final List formats;
private final Integer outputStartIndex;
private Subtitles(BuilderImpl builder) {
this.formats = builder.formats;
this.outputStartIndex = builder.outputStartIndex;
}
/**
*
* Specify the output format for your subtitle file; if you select both WebVTT (vtt
) and SubRip (
* srt
) formats, two output files are generated.
*
*
* 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 #hasFormats} method.
*
*
* @return Specify the output format for your subtitle file; if you select both WebVTT (vtt
) and SubRip
* (srt
) formats, two output files are generated.
*/
public final List formats() {
return SubtitleFormatsCopier.copyStringToEnum(formats);
}
/**
* For responses, this returns true if the service returned a value for the Formats 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 hasFormats() {
return formats != null && !(formats instanceof SdkAutoConstructList);
}
/**
*
* Specify the output format for your subtitle file; if you select both WebVTT (vtt
) and SubRip (
* srt
) formats, two output files are generated.
*
*
* 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 #hasFormats} method.
*
*
* @return Specify the output format for your subtitle file; if you select both WebVTT (vtt
) and SubRip
* (srt
) formats, two output files are generated.
*/
public final List formatsAsStrings() {
return formats;
}
/**
*
* Specify the starting value that is assigned to the first subtitle segment.
*
*
* The default start index for Amazon Transcribe is 0
, which differs from the more widely used standard
* of 1
. If you're uncertain which value to use, we recommend choosing 1
, as this may
* improve compatibility with other services.
*
*
* @return Specify the starting value that is assigned to the first subtitle segment.
*
* The default start index for Amazon Transcribe is 0
, which differs from the more widely used
* standard of 1
. If you're uncertain which value to use, we recommend choosing 1
,
* as this may improve compatibility with other services.
*/
public final Integer outputStartIndex() {
return outputStartIndex;
}
@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(hasFormats() ? formatsAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(outputStartIndex());
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 Subtitles)) {
return false;
}
Subtitles other = (Subtitles) obj;
return hasFormats() == other.hasFormats() && Objects.equals(formatsAsStrings(), other.formatsAsStrings())
&& Objects.equals(outputStartIndex(), other.outputStartIndex());
}
/**
* 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("Subtitles").add("Formats", hasFormats() ? formatsAsStrings() : null)
.add("OutputStartIndex", outputStartIndex()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Formats":
return Optional.ofNullable(clazz.cast(formatsAsStrings()));
case "OutputStartIndex":
return Optional.ofNullable(clazz.cast(outputStartIndex()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* The default start index for Amazon Transcribe is 0
, which differs from the more widely
* used standard of 1
. If you're uncertain which value to use, we recommend choosing
* 1
, as this may improve compatibility with other services.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder outputStartIndex(Integer outputStartIndex);
}
static final class BuilderImpl implements Builder {
private List formats = DefaultSdkAutoConstructList.getInstance();
private Integer outputStartIndex;
private BuilderImpl() {
}
private BuilderImpl(Subtitles model) {
formatsWithStrings(model.formats);
outputStartIndex(model.outputStartIndex);
}
public final Collection getFormats() {
if (formats instanceof SdkAutoConstructList) {
return null;
}
return formats;
}
public final void setFormats(Collection formats) {
this.formats = SubtitleFormatsCopier.copy(formats);
}
@Override
public final Builder formatsWithStrings(Collection formats) {
this.formats = SubtitleFormatsCopier.copy(formats);
return this;
}
@Override
@SafeVarargs
public final Builder formatsWithStrings(String... formats) {
formatsWithStrings(Arrays.asList(formats));
return this;
}
@Override
public final Builder formats(Collection formats) {
this.formats = SubtitleFormatsCopier.copyEnumToString(formats);
return this;
}
@Override
@SafeVarargs
public final Builder formats(SubtitleFormat... formats) {
formats(Arrays.asList(formats));
return this;
}
public final Integer getOutputStartIndex() {
return outputStartIndex;
}
public final void setOutputStartIndex(Integer outputStartIndex) {
this.outputStartIndex = outputStartIndex;
}
@Override
public final Builder outputStartIndex(Integer outputStartIndex) {
this.outputStartIndex = outputStartIndex;
return this;
}
@Override
public Subtitles build() {
return new Subtitles(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}