
software.amazon.awssdk.services.ec2.model.Route 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.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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes a route in a route table.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Route implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField DESTINATION_CIDR_BLOCK_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("DestinationCidrBlock")
.getter(getter(Route::destinationCidrBlock))
.setter(setter(Builder::destinationCidrBlock))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DestinationCidrBlock")
.unmarshallLocationName("destinationCidrBlock").build()).build();
private static final SdkField DESTINATION_IPV6_CIDR_BLOCK_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("DestinationIpv6CidrBlock")
.getter(getter(Route::destinationIpv6CidrBlock))
.setter(setter(Builder::destinationIpv6CidrBlock))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DestinationIpv6CidrBlock")
.unmarshallLocationName("destinationIpv6CidrBlock").build()).build();
private static final SdkField DESTINATION_PREFIX_LIST_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("DestinationPrefixListId")
.getter(getter(Route::destinationPrefixListId))
.setter(setter(Builder::destinationPrefixListId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DestinationPrefixListId")
.unmarshallLocationName("destinationPrefixListId").build()).build();
private static final SdkField EGRESS_ONLY_INTERNET_GATEWAY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("EgressOnlyInternetGatewayId")
.getter(getter(Route::egressOnlyInternetGatewayId))
.setter(setter(Builder::egressOnlyInternetGatewayId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EgressOnlyInternetGatewayId")
.unmarshallLocationName("egressOnlyInternetGatewayId").build()).build();
private static final SdkField GATEWAY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("GatewayId")
.getter(getter(Route::gatewayId))
.setter(setter(Builder::gatewayId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GatewayId")
.unmarshallLocationName("gatewayId").build()).build();
private static final SdkField INSTANCE_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("InstanceId")
.getter(getter(Route::instanceId))
.setter(setter(Builder::instanceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceId")
.unmarshallLocationName("instanceId").build()).build();
private static final SdkField INSTANCE_OWNER_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("InstanceOwnerId")
.getter(getter(Route::instanceOwnerId))
.setter(setter(Builder::instanceOwnerId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceOwnerId")
.unmarshallLocationName("instanceOwnerId").build()).build();
private static final SdkField NAT_GATEWAY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("NatGatewayId")
.getter(getter(Route::natGatewayId))
.setter(setter(Builder::natGatewayId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NatGatewayId")
.unmarshallLocationName("natGatewayId").build()).build();
private static final SdkField TRANSIT_GATEWAY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("TransitGatewayId")
.getter(getter(Route::transitGatewayId))
.setter(setter(Builder::transitGatewayId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TransitGatewayId")
.unmarshallLocationName("transitGatewayId").build()).build();
private static final SdkField LOCAL_GATEWAY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("LocalGatewayId")
.getter(getter(Route::localGatewayId))
.setter(setter(Builder::localGatewayId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LocalGatewayId")
.unmarshallLocationName("localGatewayId").build()).build();
private static final SdkField CARRIER_GATEWAY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("CarrierGatewayId")
.getter(getter(Route::carrierGatewayId))
.setter(setter(Builder::carrierGatewayId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CarrierGatewayId")
.unmarshallLocationName("carrierGatewayId").build()).build();
private static final SdkField NETWORK_INTERFACE_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("NetworkInterfaceId")
.getter(getter(Route::networkInterfaceId))
.setter(setter(Builder::networkInterfaceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NetworkInterfaceId")
.unmarshallLocationName("networkInterfaceId").build()).build();
private static final SdkField ORIGIN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Origin")
.getter(getter(Route::originAsString))
.setter(setter(Builder::origin))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Origin")
.unmarshallLocationName("origin").build()).build();
private static final SdkField STATE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("State")
.getter(getter(Route::stateAsString))
.setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State")
.unmarshallLocationName("state").build()).build();
private static final SdkField VPC_PEERING_CONNECTION_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("VpcPeeringConnectionId")
.getter(getter(Route::vpcPeeringConnectionId))
.setter(setter(Builder::vpcPeeringConnectionId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VpcPeeringConnectionId")
.unmarshallLocationName("vpcPeeringConnectionId").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DESTINATION_CIDR_BLOCK_FIELD,
DESTINATION_IPV6_CIDR_BLOCK_FIELD, DESTINATION_PREFIX_LIST_ID_FIELD, EGRESS_ONLY_INTERNET_GATEWAY_ID_FIELD,
GATEWAY_ID_FIELD, INSTANCE_ID_FIELD, INSTANCE_OWNER_ID_FIELD, NAT_GATEWAY_ID_FIELD, TRANSIT_GATEWAY_ID_FIELD,
LOCAL_GATEWAY_ID_FIELD, CARRIER_GATEWAY_ID_FIELD, NETWORK_INTERFACE_ID_FIELD, ORIGIN_FIELD, STATE_FIELD,
VPC_PEERING_CONNECTION_ID_FIELD));
private static final long serialVersionUID = 1L;
private final String destinationCidrBlock;
private final String destinationIpv6CidrBlock;
private final String destinationPrefixListId;
private final String egressOnlyInternetGatewayId;
private final String gatewayId;
private final String instanceId;
private final String instanceOwnerId;
private final String natGatewayId;
private final String transitGatewayId;
private final String localGatewayId;
private final String carrierGatewayId;
private final String networkInterfaceId;
private final String origin;
private final String state;
private final String vpcPeeringConnectionId;
private Route(BuilderImpl builder) {
this.destinationCidrBlock = builder.destinationCidrBlock;
this.destinationIpv6CidrBlock = builder.destinationIpv6CidrBlock;
this.destinationPrefixListId = builder.destinationPrefixListId;
this.egressOnlyInternetGatewayId = builder.egressOnlyInternetGatewayId;
this.gatewayId = builder.gatewayId;
this.instanceId = builder.instanceId;
this.instanceOwnerId = builder.instanceOwnerId;
this.natGatewayId = builder.natGatewayId;
this.transitGatewayId = builder.transitGatewayId;
this.localGatewayId = builder.localGatewayId;
this.carrierGatewayId = builder.carrierGatewayId;
this.networkInterfaceId = builder.networkInterfaceId;
this.origin = builder.origin;
this.state = builder.state;
this.vpcPeeringConnectionId = builder.vpcPeeringConnectionId;
}
/**
*
* The IPv4 CIDR block used for the destination match.
*
*
* @return The IPv4 CIDR block used for the destination match.
*/
public String destinationCidrBlock() {
return destinationCidrBlock;
}
/**
*
* The IPv6 CIDR block used for the destination match.
*
*
* @return The IPv6 CIDR block used for the destination match.
*/
public String destinationIpv6CidrBlock() {
return destinationIpv6CidrBlock;
}
/**
*
* The prefix of the AWS service.
*
*
* @return The prefix of the AWS service.
*/
public String destinationPrefixListId() {
return destinationPrefixListId;
}
/**
*
* The ID of the egress-only internet gateway.
*
*
* @return The ID of the egress-only internet gateway.
*/
public String egressOnlyInternetGatewayId() {
return egressOnlyInternetGatewayId;
}
/**
*
* The ID of a gateway attached to your VPC.
*
*
* @return The ID of a gateway attached to your VPC.
*/
public String gatewayId() {
return gatewayId;
}
/**
*
* The ID of a NAT instance in your VPC.
*
*
* @return The ID of a NAT instance in your VPC.
*/
public String instanceId() {
return instanceId;
}
/**
*
* The AWS account ID of the owner of the instance.
*
*
* @return The AWS account ID of the owner of the instance.
*/
public String instanceOwnerId() {
return instanceOwnerId;
}
/**
*
* The ID of a NAT gateway.
*
*
* @return The ID of a NAT gateway.
*/
public String natGatewayId() {
return natGatewayId;
}
/**
*
* The ID of a transit gateway.
*
*
* @return The ID of a transit gateway.
*/
public String transitGatewayId() {
return transitGatewayId;
}
/**
*
* The ID of the local gateway.
*
*
* @return The ID of the local gateway.
*/
public String localGatewayId() {
return localGatewayId;
}
/**
*
* The ID of the carrier gateway.
*
*
* @return The ID of the carrier gateway.
*/
public String carrierGatewayId() {
return carrierGatewayId;
}
/**
*
* The ID of the network interface.
*
*
* @return The ID of the network interface.
*/
public String networkInterfaceId() {
return networkInterfaceId;
}
/**
*
* Describes how the route was created.
*
*
* -
*
* CreateRouteTable
- The route was automatically created when the route table was created.
*
*
* -
*
* CreateRoute
- The route was manually added to the route table.
*
*
* -
*
* EnableVgwRoutePropagation
- The route was propagated by route propagation.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #origin} will
* return {@link RouteOrigin#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #originAsString}.
*
*
* @return Describes how the route was created.
*
* -
*
* CreateRouteTable
- The route was automatically created when the route table was created.
*
*
* -
*
* CreateRoute
- The route was manually added to the route table.
*
*
* -
*
* EnableVgwRoutePropagation
- The route was propagated by route propagation.
*
*
* @see RouteOrigin
*/
public RouteOrigin origin() {
return RouteOrigin.fromValue(origin);
}
/**
*
* Describes how the route was created.
*
*
* -
*
* CreateRouteTable
- The route was automatically created when the route table was created.
*
*
* -
*
* CreateRoute
- The route was manually added to the route table.
*
*
* -
*
* EnableVgwRoutePropagation
- The route was propagated by route propagation.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #origin} will
* return {@link RouteOrigin#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #originAsString}.
*
*
* @return Describes how the route was created.
*
* -
*
* CreateRouteTable
- The route was automatically created when the route table was created.
*
*
* -
*
* CreateRoute
- The route was manually added to the route table.
*
*
* -
*
* EnableVgwRoutePropagation
- The route was propagated by route propagation.
*
*
* @see RouteOrigin
*/
public String originAsString() {
return origin;
}
/**
*
* The state of the route. The blackhole
state indicates that the route's target isn't available (for
* example, the specified gateway isn't attached to the VPC, or the specified NAT instance has been terminated).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link RouteState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the route. The blackhole
state indicates that the route's target isn't
* available (for example, the specified gateway isn't attached to the VPC, or the specified NAT instance
* has been terminated).
* @see RouteState
*/
public RouteState state() {
return RouteState.fromValue(state);
}
/**
*
* The state of the route. The blackhole
state indicates that the route's target isn't available (for
* example, the specified gateway isn't attached to the VPC, or the specified NAT instance has been terminated).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link RouteState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the route. The blackhole
state indicates that the route's target isn't
* available (for example, the specified gateway isn't attached to the VPC, or the specified NAT instance
* has been terminated).
* @see RouteState
*/
public String stateAsString() {
return state;
}
/**
*
* The ID of a VPC peering connection.
*
*
* @return The ID of a VPC peering connection.
*/
public String vpcPeeringConnectionId() {
return vpcPeeringConnectionId;
}
@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(destinationIpv6CidrBlock());
hashCode = 31 * hashCode + Objects.hashCode(destinationPrefixListId());
hashCode = 31 * hashCode + Objects.hashCode(egressOnlyInternetGatewayId());
hashCode = 31 * hashCode + Objects.hashCode(gatewayId());
hashCode = 31 * hashCode + Objects.hashCode(instanceId());
hashCode = 31 * hashCode + Objects.hashCode(instanceOwnerId());
hashCode = 31 * hashCode + Objects.hashCode(natGatewayId());
hashCode = 31 * hashCode + Objects.hashCode(transitGatewayId());
hashCode = 31 * hashCode + Objects.hashCode(localGatewayId());
hashCode = 31 * hashCode + Objects.hashCode(carrierGatewayId());
hashCode = 31 * hashCode + Objects.hashCode(networkInterfaceId());
hashCode = 31 * hashCode + Objects.hashCode(originAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(vpcPeeringConnectionId());
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 Route)) {
return false;
}
Route other = (Route) obj;
return Objects.equals(destinationCidrBlock(), other.destinationCidrBlock())
&& Objects.equals(destinationIpv6CidrBlock(), other.destinationIpv6CidrBlock())
&& Objects.equals(destinationPrefixListId(), other.destinationPrefixListId())
&& Objects.equals(egressOnlyInternetGatewayId(), other.egressOnlyInternetGatewayId())
&& Objects.equals(gatewayId(), other.gatewayId()) && Objects.equals(instanceId(), other.instanceId())
&& Objects.equals(instanceOwnerId(), other.instanceOwnerId())
&& Objects.equals(natGatewayId(), other.natGatewayId())
&& Objects.equals(transitGatewayId(), other.transitGatewayId())
&& Objects.equals(localGatewayId(), other.localGatewayId())
&& Objects.equals(carrierGatewayId(), other.carrierGatewayId())
&& Objects.equals(networkInterfaceId(), other.networkInterfaceId())
&& Objects.equals(originAsString(), other.originAsString())
&& Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(vpcPeeringConnectionId(), other.vpcPeeringConnectionId());
}
/**
* 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("Route").add("DestinationCidrBlock", destinationCidrBlock())
.add("DestinationIpv6CidrBlock", destinationIpv6CidrBlock())
.add("DestinationPrefixListId", destinationPrefixListId())
.add("EgressOnlyInternetGatewayId", egressOnlyInternetGatewayId()).add("GatewayId", gatewayId())
.add("InstanceId", instanceId()).add("InstanceOwnerId", instanceOwnerId()).add("NatGatewayId", natGatewayId())
.add("TransitGatewayId", transitGatewayId()).add("LocalGatewayId", localGatewayId())
.add("CarrierGatewayId", carrierGatewayId()).add("NetworkInterfaceId", networkInterfaceId())
.add("Origin", originAsString()).add("State", stateAsString())
.add("VpcPeeringConnectionId", vpcPeeringConnectionId()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "DestinationCidrBlock":
return Optional.ofNullable(clazz.cast(destinationCidrBlock()));
case "DestinationIpv6CidrBlock":
return Optional.ofNullable(clazz.cast(destinationIpv6CidrBlock()));
case "DestinationPrefixListId":
return Optional.ofNullable(clazz.cast(destinationPrefixListId()));
case "EgressOnlyInternetGatewayId":
return Optional.ofNullable(clazz.cast(egressOnlyInternetGatewayId()));
case "GatewayId":
return Optional.ofNullable(clazz.cast(gatewayId()));
case "InstanceId":
return Optional.ofNullable(clazz.cast(instanceId()));
case "InstanceOwnerId":
return Optional.ofNullable(clazz.cast(instanceOwnerId()));
case "NatGatewayId":
return Optional.ofNullable(clazz.cast(natGatewayId()));
case "TransitGatewayId":
return Optional.ofNullable(clazz.cast(transitGatewayId()));
case "LocalGatewayId":
return Optional.ofNullable(clazz.cast(localGatewayId()));
case "CarrierGatewayId":
return Optional.ofNullable(clazz.cast(carrierGatewayId()));
case "NetworkInterfaceId":
return Optional.ofNullable(clazz.cast(networkInterfaceId()));
case "Origin":
return Optional.ofNullable(clazz.cast(originAsString()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "VpcPeeringConnectionId":
return Optional.ofNullable(clazz.cast(vpcPeeringConnectionId()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function