software.amazon.awssdk.services.ec2.model.InstanceEventWindow Maven / Gradle / Ivy
Show all versions of ec2 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.ec2.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
*
* The event window.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class InstanceEventWindow implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField INSTANCE_EVENT_WINDOW_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("InstanceEventWindowId")
.getter(getter(InstanceEventWindow::instanceEventWindowId))
.setter(setter(Builder::instanceEventWindowId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceEventWindowId")
.unmarshallLocationName("instanceEventWindowId").build()).build();
private static final SdkField> TIME_RANGES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("TimeRanges")
.getter(getter(InstanceEventWindow::timeRanges))
.setter(setter(Builder::timeRanges))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimeRangeSet")
.unmarshallLocationName("timeRangeSet").build(),
ListTrait
.builder()
.memberLocationName("item")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(InstanceEventWindowTimeRange::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Item").unmarshallLocationName("item").build()).build())
.build()).build();
private static final SdkField NAME_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Name")
.getter(getter(InstanceEventWindow::name))
.setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name")
.unmarshallLocationName("name").build()).build();
private static final SdkField CRON_EXPRESSION_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("CronExpression")
.getter(getter(InstanceEventWindow::cronExpression))
.setter(setter(Builder::cronExpression))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CronExpression")
.unmarshallLocationName("cronExpression").build()).build();
private static final SdkField ASSOCIATION_TARGET_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("AssociationTarget")
.getter(getter(InstanceEventWindow::associationTarget))
.setter(setter(Builder::associationTarget))
.constructor(InstanceEventWindowAssociationTarget::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssociationTarget")
.unmarshallLocationName("associationTarget").build()).build();
private static final SdkField STATE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("State")
.getter(getter(InstanceEventWindow::stateAsString))
.setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State")
.unmarshallLocationName("state").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(InstanceEventWindow::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TagSet")
.unmarshallLocationName("tagSet").build(),
ListTrait
.builder()
.memberLocationName("item")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Item").unmarshallLocationName("item").build()).build())
.build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
INSTANCE_EVENT_WINDOW_ID_FIELD, TIME_RANGES_FIELD, NAME_FIELD, CRON_EXPRESSION_FIELD, ASSOCIATION_TARGET_FIELD,
STATE_FIELD, TAGS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("InstanceEventWindowId", INSTANCE_EVENT_WINDOW_ID_FIELD);
put("TimeRangeSet", TIME_RANGES_FIELD);
put("Name", NAME_FIELD);
put("CronExpression", CRON_EXPRESSION_FIELD);
put("AssociationTarget", ASSOCIATION_TARGET_FIELD);
put("State", STATE_FIELD);
put("TagSet", TAGS_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String instanceEventWindowId;
private final List timeRanges;
private final String name;
private final String cronExpression;
private final InstanceEventWindowAssociationTarget associationTarget;
private final String state;
private final List tags;
private InstanceEventWindow(BuilderImpl builder) {
this.instanceEventWindowId = builder.instanceEventWindowId;
this.timeRanges = builder.timeRanges;
this.name = builder.name;
this.cronExpression = builder.cronExpression;
this.associationTarget = builder.associationTarget;
this.state = builder.state;
this.tags = builder.tags;
}
/**
*
* The ID of the event window.
*
*
* @return The ID of the event window.
*/
public final String instanceEventWindowId() {
return instanceEventWindowId;
}
/**
* For responses, this returns true if the service returned a value for the TimeRanges 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 hasTimeRanges() {
return timeRanges != null && !(timeRanges instanceof SdkAutoConstructList);
}
/**
*
* One or more time ranges defined for the event window.
*
*
* 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 #hasTimeRanges} method.
*
*
* @return One or more time ranges defined for the event window.
*/
public final List timeRanges() {
return timeRanges;
}
/**
*
* The name of the event window.
*
*
* @return The name of the event window.
*/
public final String name() {
return name;
}
/**
*
* The cron expression defined for the event window.
*
*
* @return The cron expression defined for the event window.
*/
public final String cronExpression() {
return cronExpression;
}
/**
*
* One or more targets associated with the event window.
*
*
* @return One or more targets associated with the event window.
*/
public final InstanceEventWindowAssociationTarget associationTarget() {
return associationTarget;
}
/**
*
* The current state of the event window.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link InstanceEventWindowState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The current state of the event window.
* @see InstanceEventWindowState
*/
public final InstanceEventWindowState state() {
return InstanceEventWindowState.fromValue(state);
}
/**
*
* The current state of the event window.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link InstanceEventWindowState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The current state of the event window.
* @see InstanceEventWindowState
*/
public final String stateAsString() {
return state;
}
/**
* For responses, this returns true if the service returned a value for the Tags 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 hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructList);
}
/**
*
* The instance tags associated with the event window.
*
*
* 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 #hasTags} method.
*
*
* @return The instance tags associated with the event window.
*/
public final List tags() {
return tags;
}
@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(instanceEventWindowId());
hashCode = 31 * hashCode + Objects.hashCode(hasTimeRanges() ? timeRanges() : null);
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(cronExpression());
hashCode = 31 * hashCode + Objects.hashCode(associationTarget());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
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 InstanceEventWindow)) {
return false;
}
InstanceEventWindow other = (InstanceEventWindow) obj;
return Objects.equals(instanceEventWindowId(), other.instanceEventWindowId()) && hasTimeRanges() == other.hasTimeRanges()
&& Objects.equals(timeRanges(), other.timeRanges()) && Objects.equals(name(), other.name())
&& Objects.equals(cronExpression(), other.cronExpression())
&& Objects.equals(associationTarget(), other.associationTarget())
&& Objects.equals(stateAsString(), other.stateAsString()) && hasTags() == other.hasTags()
&& Objects.equals(tags(), other.tags());
}
/**
* 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("InstanceEventWindow").add("InstanceEventWindowId", instanceEventWindowId())
.add("TimeRanges", hasTimeRanges() ? timeRanges() : null).add("Name", name())
.add("CronExpression", cronExpression()).add("AssociationTarget", associationTarget())
.add("State", stateAsString()).add("Tags", hasTags() ? tags() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "InstanceEventWindowId":
return Optional.ofNullable(clazz.cast(instanceEventWindowId()));
case "TimeRanges":
return Optional.ofNullable(clazz.cast(timeRanges()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "CronExpression":
return Optional.ofNullable(clazz.cast(cronExpression()));
case "AssociationTarget":
return Optional.ofNullable(clazz.cast(associationTarget()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function