
software.amazon.awssdk.services.mediaconnect.model.Gateway 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.mediaconnect.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.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 settings for a gateway, including its networks.
*/
@Generated("software.amazon.awssdk:codegen")
public final class Gateway implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField> EGRESS_CIDR_BLOCKS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("EgressCidrBlocks")
.getter(getter(Gateway::egressCidrBlocks))
.setter(setter(Builder::egressCidrBlocks))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("egressCidrBlocks").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 GATEWAY_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("GatewayArn").getter(getter(Gateway::gatewayArn)).setter(setter(Builder::gatewayArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("gatewayArn").build()).build();
private static final SdkField> GATEWAY_MESSAGES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("GatewayMessages")
.getter(getter(Gateway::gatewayMessages))
.setter(setter(Builder::gatewayMessages))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("gatewayMessages").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(MessageDetail::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField GATEWAY_STATE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("GatewayState").getter(getter(Gateway::gatewayStateAsString)).setter(setter(Builder::gatewayState))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("gatewayState").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(Gateway::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField> NETWORKS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Networks")
.getter(getter(Gateway::networks))
.setter(setter(Builder::networks))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("networks").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(GatewayNetwork::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(EGRESS_CIDR_BLOCKS_FIELD,
GATEWAY_ARN_FIELD, GATEWAY_MESSAGES_FIELD, GATEWAY_STATE_FIELD, NAME_FIELD, NETWORKS_FIELD));
private static final long serialVersionUID = 1L;
private final List egressCidrBlocks;
private final String gatewayArn;
private final List gatewayMessages;
private final String gatewayState;
private final String name;
private final List networks;
private Gateway(BuilderImpl builder) {
this.egressCidrBlocks = builder.egressCidrBlocks;
this.gatewayArn = builder.gatewayArn;
this.gatewayMessages = builder.gatewayMessages;
this.gatewayState = builder.gatewayState;
this.name = builder.name;
this.networks = builder.networks;
}
/**
* For responses, this returns true if the service returned a value for the EgressCidrBlocks 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 hasEgressCidrBlocks() {
return egressCidrBlocks != null && !(egressCidrBlocks instanceof SdkAutoConstructList);
}
/**
* The range of IP addresses that contribute content or initiate output requests for flows communicating with this
* gateway. These IP addresses should be in the form of a Classless Inter-Domain Routing (CIDR) block; for example,
* 10.0.0.0/16.
*
* 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 #hasEgressCidrBlocks} method.
*
*
* @return The range of IP addresses that contribute content or initiate output requests for flows communicating
* with this gateway. These IP addresses should be in the form of a Classless Inter-Domain Routing (CIDR)
* block; for example, 10.0.0.0/16.
*/
public final List egressCidrBlocks() {
return egressCidrBlocks;
}
/**
* The Amazon Resource Name (ARN) of the gateway.
*
* @return The Amazon Resource Name (ARN) of the gateway.
*/
public final String gatewayArn() {
return gatewayArn;
}
/**
* For responses, this returns true if the service returned a value for the GatewayMessages 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 hasGatewayMessages() {
return gatewayMessages != null && !(gatewayMessages instanceof SdkAutoConstructList);
}
/**
* Returns the value of the GatewayMessages property for this object.
*
* 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 #hasGatewayMessages} method.
*
*
* @return The value of the GatewayMessages property for this object.
*/
public final List gatewayMessages() {
return gatewayMessages;
}
/**
* The current status of the gateway.
*
* If the service returns an enum value that is not available in the current SDK version, {@link #gatewayState} will
* return {@link GatewayState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #gatewayStateAsString}.
*
*
* @return The current status of the gateway.
* @see GatewayState
*/
public final GatewayState gatewayState() {
return GatewayState.fromValue(gatewayState);
}
/**
* The current status of the gateway.
*
* If the service returns an enum value that is not available in the current SDK version, {@link #gatewayState} will
* return {@link GatewayState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #gatewayStateAsString}.
*
*
* @return The current status of the gateway.
* @see GatewayState
*/
public final String gatewayStateAsString() {
return gatewayState;
}
/**
* The name of the gateway. This name can not be modified after the gateway is created.
*
* @return The name of the gateway. This name can not be modified after the gateway is created.
*/
public final String name() {
return name;
}
/**
* For responses, this returns true if the service returned a value for the Networks 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 hasNetworks() {
return networks != null && !(networks instanceof SdkAutoConstructList);
}
/**
* The list of networks in the gateway.
*
* 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 #hasNetworks} method.
*
*
* @return The list of networks in the gateway.
*/
public final List networks() {
return networks;
}
@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(hasEgressCidrBlocks() ? egressCidrBlocks() : null);
hashCode = 31 * hashCode + Objects.hashCode(gatewayArn());
hashCode = 31 * hashCode + Objects.hashCode(hasGatewayMessages() ? gatewayMessages() : null);
hashCode = 31 * hashCode + Objects.hashCode(gatewayStateAsString());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(hasNetworks() ? networks() : 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 Gateway)) {
return false;
}
Gateway other = (Gateway) obj;
return hasEgressCidrBlocks() == other.hasEgressCidrBlocks()
&& Objects.equals(egressCidrBlocks(), other.egressCidrBlocks())
&& Objects.equals(gatewayArn(), other.gatewayArn()) && hasGatewayMessages() == other.hasGatewayMessages()
&& Objects.equals(gatewayMessages(), other.gatewayMessages())
&& Objects.equals(gatewayStateAsString(), other.gatewayStateAsString()) && Objects.equals(name(), other.name())
&& hasNetworks() == other.hasNetworks() && Objects.equals(networks(), other.networks());
}
/**
* 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("Gateway").add("EgressCidrBlocks", hasEgressCidrBlocks() ? egressCidrBlocks() : null)
.add("GatewayArn", gatewayArn()).add("GatewayMessages", hasGatewayMessages() ? gatewayMessages() : null)
.add("GatewayState", gatewayStateAsString()).add("Name", name())
.add("Networks", hasNetworks() ? networks() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "EgressCidrBlocks":
return Optional.ofNullable(clazz.cast(egressCidrBlocks()));
case "GatewayArn":
return Optional.ofNullable(clazz.cast(gatewayArn()));
case "GatewayMessages":
return Optional.ofNullable(clazz.cast(gatewayMessages()));
case "GatewayState":
return Optional.ofNullable(clazz.cast(gatewayStateAsString()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Networks":
return Optional.ofNullable(clazz.cast(networks()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function