
software.amazon.awssdk.services.ec2.model.TransitGatewayRoute 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.ec2.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;
/**
*
* Describes a route for a transit gateway route table.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TransitGatewayRoute implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField DESTINATION_CIDR_BLOCK_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("DestinationCidrBlock")
.getter(getter(TransitGatewayRoute::destinationCidrBlock))
.setter(setter(Builder::destinationCidrBlock))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DestinationCidrBlock")
.unmarshallLocationName("destinationCidrBlock").build()).build();
private static final SdkField PREFIX_LIST_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("PrefixListId")
.getter(getter(TransitGatewayRoute::prefixListId))
.setter(setter(Builder::prefixListId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrefixListId")
.unmarshallLocationName("prefixListId").build()).build();
private static final SdkField> TRANSIT_GATEWAY_ATTACHMENTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("TransitGatewayAttachments")
.getter(getter(TransitGatewayRoute::transitGatewayAttachments))
.setter(setter(Builder::transitGatewayAttachments))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TransitGatewayAttachments")
.unmarshallLocationName("transitGatewayAttachments").build(),
ListTrait
.builder()
.memberLocationName("item")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(TransitGatewayRouteAttachment::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Item").unmarshallLocationName("item").build()).build())
.build()).build();
private static final SdkField TYPE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Type")
.getter(getter(TransitGatewayRoute::typeAsString))
.setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type")
.unmarshallLocationName("type").build()).build();
private static final SdkField STATE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("State")
.getter(getter(TransitGatewayRoute::stateAsString))
.setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State")
.unmarshallLocationName("state").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DESTINATION_CIDR_BLOCK_FIELD,
PREFIX_LIST_ID_FIELD, TRANSIT_GATEWAY_ATTACHMENTS_FIELD, TYPE_FIELD, STATE_FIELD));
private static final long serialVersionUID = 1L;
private final String destinationCidrBlock;
private final String prefixListId;
private final List transitGatewayAttachments;
private final String type;
private final String state;
private TransitGatewayRoute(BuilderImpl builder) {
this.destinationCidrBlock = builder.destinationCidrBlock;
this.prefixListId = builder.prefixListId;
this.transitGatewayAttachments = builder.transitGatewayAttachments;
this.type = builder.type;
this.state = builder.state;
}
/**
*
* The CIDR block used for destination matches.
*
*
* @return The CIDR block used for destination matches.
*/
public String destinationCidrBlock() {
return destinationCidrBlock;
}
/**
*
* The ID of the prefix list used for destination matches.
*
*
* @return The ID of the prefix list used for destination matches.
*/
public String prefixListId() {
return prefixListId;
}
/**
* Returns true if the TransitGatewayAttachments property was specified by the sender (it may be empty), or false if
* the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
* service.
*/
public boolean hasTransitGatewayAttachments() {
return transitGatewayAttachments != null && !(transitGatewayAttachments instanceof SdkAutoConstructList);
}
/**
*
* The attachments.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasTransitGatewayAttachments()} to see if a value was sent in this field.
*
*
* @return The attachments.
*/
public List transitGatewayAttachments() {
return transitGatewayAttachments;
}
/**
*
* The route type.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link TransitGatewayRouteType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The route type.
* @see TransitGatewayRouteType
*/
public TransitGatewayRouteType type() {
return TransitGatewayRouteType.fromValue(type);
}
/**
*
* The route type.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link TransitGatewayRouteType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The route type.
* @see TransitGatewayRouteType
*/
public String typeAsString() {
return type;
}
/**
*
* The state of the route.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link TransitGatewayRouteState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the route.
* @see TransitGatewayRouteState
*/
public TransitGatewayRouteState state() {
return TransitGatewayRouteState.fromValue(state);
}
/**
*
* The state of the route.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link TransitGatewayRouteState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the route.
* @see TransitGatewayRouteState
*/
public String stateAsString() {
return state;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(destinationCidrBlock());
hashCode = 31 * hashCode + Objects.hashCode(prefixListId());
hashCode = 31 * hashCode + Objects.hashCode(transitGatewayAttachments());
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TransitGatewayRoute)) {
return false;
}
TransitGatewayRoute other = (TransitGatewayRoute) obj;
return Objects.equals(destinationCidrBlock(), other.destinationCidrBlock())
&& Objects.equals(prefixListId(), other.prefixListId())
&& Objects.equals(transitGatewayAttachments(), other.transitGatewayAttachments())
&& Objects.equals(typeAsString(), other.typeAsString()) && Objects.equals(stateAsString(), other.stateAsString());
}
/**
* 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 String toString() {
return ToString.builder("TransitGatewayRoute").add("DestinationCidrBlock", destinationCidrBlock())
.add("PrefixListId", prefixListId()).add("TransitGatewayAttachments", transitGatewayAttachments())
.add("Type", typeAsString()).add("State", stateAsString()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "DestinationCidrBlock":
return Optional.ofNullable(clazz.cast(destinationCidrBlock()));
case "PrefixListId":
return Optional.ofNullable(clazz.cast(prefixListId()));
case "TransitGatewayAttachments":
return Optional.ofNullable(clazz.cast(transitGatewayAttachments()));
case "Type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function