
software.amazon.awssdk.services.mediatailor.model.ScheduleEntry 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.mediatailor.model;
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 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.traits.TimestampFormatTrait;
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;
/**
*
* The properties for a schedule.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ScheduleEntry implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField APPROXIMATE_DURATION_SECONDS_FIELD = SdkField
. builder(MarshallingType.LONG)
.memberName("ApproximateDurationSeconds")
.getter(getter(ScheduleEntry::approximateDurationSeconds))
.setter(setter(Builder::approximateDurationSeconds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ApproximateDurationSeconds").build())
.build();
private static final SdkField APPROXIMATE_START_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("ApproximateStartTime")
.getter(getter(ScheduleEntry::approximateStartTime))
.setter(setter(Builder::approximateStartTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ApproximateStartTime").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.UNIX_TIMESTAMP)).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Arn")
.getter(getter(ScheduleEntry::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Arn").build()).build();
private static final SdkField CHANNEL_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ChannelName").getter(getter(ScheduleEntry::channelName)).setter(setter(Builder::channelName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ChannelName").build()).build();
private static final SdkField LIVE_SOURCE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LiveSourceName").getter(getter(ScheduleEntry::liveSourceName)).setter(setter(Builder::liveSourceName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LiveSourceName").build()).build();
private static final SdkField PROGRAM_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ProgramName").getter(getter(ScheduleEntry::programName)).setter(setter(Builder::programName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ProgramName").build()).build();
private static final SdkField> SCHEDULE_AD_BREAKS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ScheduleAdBreaks")
.getter(getter(ScheduleEntry::scheduleAdBreaks))
.setter(setter(Builder::scheduleAdBreaks))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleAdBreaks").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ScheduleAdBreak::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField SCHEDULE_ENTRY_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ScheduleEntryType").getter(getter(ScheduleEntry::scheduleEntryTypeAsString))
.setter(setter(Builder::scheduleEntryType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleEntryType").build()).build();
private static final SdkField SOURCE_LOCATION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SourceLocationName").getter(getter(ScheduleEntry::sourceLocationName))
.setter(setter(Builder::sourceLocationName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceLocationName").build())
.build();
private static final SdkField VOD_SOURCE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("VodSourceName").getter(getter(ScheduleEntry::vodSourceName)).setter(setter(Builder::vodSourceName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VodSourceName").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
APPROXIMATE_DURATION_SECONDS_FIELD, APPROXIMATE_START_TIME_FIELD, ARN_FIELD, CHANNEL_NAME_FIELD,
LIVE_SOURCE_NAME_FIELD, PROGRAM_NAME_FIELD, SCHEDULE_AD_BREAKS_FIELD, SCHEDULE_ENTRY_TYPE_FIELD,
SOURCE_LOCATION_NAME_FIELD, VOD_SOURCE_NAME_FIELD));
private static final long serialVersionUID = 1L;
private final Long approximateDurationSeconds;
private final Instant approximateStartTime;
private final String arn;
private final String channelName;
private final String liveSourceName;
private final String programName;
private final List scheduleAdBreaks;
private final String scheduleEntryType;
private final String sourceLocationName;
private final String vodSourceName;
private ScheduleEntry(BuilderImpl builder) {
this.approximateDurationSeconds = builder.approximateDurationSeconds;
this.approximateStartTime = builder.approximateStartTime;
this.arn = builder.arn;
this.channelName = builder.channelName;
this.liveSourceName = builder.liveSourceName;
this.programName = builder.programName;
this.scheduleAdBreaks = builder.scheduleAdBreaks;
this.scheduleEntryType = builder.scheduleEntryType;
this.sourceLocationName = builder.sourceLocationName;
this.vodSourceName = builder.vodSourceName;
}
/**
*
* The approximate duration of this program, in seconds.
*
*
* @return The approximate duration of this program, in seconds.
*/
public final Long approximateDurationSeconds() {
return approximateDurationSeconds;
}
/**
*
* The approximate time that the program will start playing.
*
*
* @return The approximate time that the program will start playing.
*/
public final Instant approximateStartTime() {
return approximateStartTime;
}
/**
*
* The ARN of the program.
*
*
* @return The ARN of the program.
*/
public final String arn() {
return arn;
}
/**
*
* The name of the channel that uses this schedule.
*
*
* @return The name of the channel that uses this schedule.
*/
public final String channelName() {
return channelName;
}
/**
*
* The name of the live source used for the program.
*
*
* @return The name of the live source used for the program.
*/
public final String liveSourceName() {
return liveSourceName;
}
/**
*
* The name of the program.
*
*
* @return The name of the program.
*/
public final String programName() {
return programName;
}
/**
* For responses, this returns true if the service returned a value for the ScheduleAdBreaks 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 hasScheduleAdBreaks() {
return scheduleAdBreaks != null && !(scheduleAdBreaks instanceof SdkAutoConstructList);
}
/**
*
* The schedule's ad break properties.
*
*
* 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 #hasScheduleAdBreaks} method.
*
*
* @return The schedule's ad break properties.
*/
public final List scheduleAdBreaks() {
return scheduleAdBreaks;
}
/**
*
* The type of schedule entry.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #scheduleEntryType}
* will return {@link ScheduleEntryType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #scheduleEntryTypeAsString}.
*
*
* @return The type of schedule entry.
* @see ScheduleEntryType
*/
public final ScheduleEntryType scheduleEntryType() {
return ScheduleEntryType.fromValue(scheduleEntryType);
}
/**
*
* The type of schedule entry.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #scheduleEntryType}
* will return {@link ScheduleEntryType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #scheduleEntryTypeAsString}.
*
*
* @return The type of schedule entry.
* @see ScheduleEntryType
*/
public final String scheduleEntryTypeAsString() {
return scheduleEntryType;
}
/**
*
* The name of the source location.
*
*
* @return The name of the source location.
*/
public final String sourceLocationName() {
return sourceLocationName;
}
/**
*
* The name of the VOD source.
*
*
* @return The name of the VOD source.
*/
public final String vodSourceName() {
return vodSourceName;
}
@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(approximateDurationSeconds());
hashCode = 31 * hashCode + Objects.hashCode(approximateStartTime());
hashCode = 31 * hashCode + Objects.hashCode(arn());
hashCode = 31 * hashCode + Objects.hashCode(channelName());
hashCode = 31 * hashCode + Objects.hashCode(liveSourceName());
hashCode = 31 * hashCode + Objects.hashCode(programName());
hashCode = 31 * hashCode + Objects.hashCode(hasScheduleAdBreaks() ? scheduleAdBreaks() : null);
hashCode = 31 * hashCode + Objects.hashCode(scheduleEntryTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(sourceLocationName());
hashCode = 31 * hashCode + Objects.hashCode(vodSourceName());
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 ScheduleEntry)) {
return false;
}
ScheduleEntry other = (ScheduleEntry) obj;
return Objects.equals(approximateDurationSeconds(), other.approximateDurationSeconds())
&& Objects.equals(approximateStartTime(), other.approximateStartTime()) && Objects.equals(arn(), other.arn())
&& Objects.equals(channelName(), other.channelName()) && Objects.equals(liveSourceName(), other.liveSourceName())
&& Objects.equals(programName(), other.programName()) && hasScheduleAdBreaks() == other.hasScheduleAdBreaks()
&& Objects.equals(scheduleAdBreaks(), other.scheduleAdBreaks())
&& Objects.equals(scheduleEntryTypeAsString(), other.scheduleEntryTypeAsString())
&& Objects.equals(sourceLocationName(), other.sourceLocationName())
&& Objects.equals(vodSourceName(), other.vodSourceName());
}
/**
* 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("ScheduleEntry").add("ApproximateDurationSeconds", approximateDurationSeconds())
.add("ApproximateStartTime", approximateStartTime()).add("Arn", arn()).add("ChannelName", channelName())
.add("LiveSourceName", liveSourceName()).add("ProgramName", programName())
.add("ScheduleAdBreaks", hasScheduleAdBreaks() ? scheduleAdBreaks() : null)
.add("ScheduleEntryType", scheduleEntryTypeAsString()).add("SourceLocationName", sourceLocationName())
.add("VodSourceName", vodSourceName()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ApproximateDurationSeconds":
return Optional.ofNullable(clazz.cast(approximateDurationSeconds()));
case "ApproximateStartTime":
return Optional.ofNullable(clazz.cast(approximateStartTime()));
case "Arn":
return Optional.ofNullable(clazz.cast(arn()));
case "ChannelName":
return Optional.ofNullable(clazz.cast(channelName()));
case "LiveSourceName":
return Optional.ofNullable(clazz.cast(liveSourceName()));
case "ProgramName":
return Optional.ofNullable(clazz.cast(programName()));
case "ScheduleAdBreaks":
return Optional.ofNullable(clazz.cast(scheduleAdBreaks()));
case "ScheduleEntryType":
return Optional.ofNullable(clazz.cast(scheduleEntryTypeAsString()));
case "SourceLocationName":
return Optional.ofNullable(clazz.cast(sourceLocationName()));
case "VodSourceName":
return Optional.ofNullable(clazz.cast(vodSourceName()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function