All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 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 getter(Function g) { return obj -> g.apply((TransitGatewayRoute) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The CIDR block used for destination matches. *

* * @param destinationCidrBlock * The CIDR block used for destination matches. * @return Returns a reference to this object so that method calls can be chained together. */ Builder destinationCidrBlock(String destinationCidrBlock); /** *

* The ID of the prefix list used for destination matches. *

* * @param prefixListId * The ID of the prefix list used for destination matches. * @return Returns a reference to this object so that method calls can be chained together. */ Builder prefixListId(String prefixListId); /** *

* The attachments. *

* * @param transitGatewayAttachments * The attachments. * @return Returns a reference to this object so that method calls can be chained together. */ Builder transitGatewayAttachments(Collection transitGatewayAttachments); /** *

* The attachments. *

* * @param transitGatewayAttachments * The attachments. * @return Returns a reference to this object so that method calls can be chained together. */ Builder transitGatewayAttachments(TransitGatewayRouteAttachment... transitGatewayAttachments); /** *

* The attachments. *

* This is a convenience that creates an instance of the {@link List.Builder} * avoiding the need to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called * immediately and its result is passed to {@link * #transitGatewayAttachments(List)}. * * @param transitGatewayAttachments * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #transitGatewayAttachments(List) */ Builder transitGatewayAttachments(Consumer... transitGatewayAttachments); /** *

* The route type. *

* * @param type * The route type. * @see TransitGatewayRouteType * @return Returns a reference to this object so that method calls can be chained together. * @see TransitGatewayRouteType */ Builder type(String type); /** *

* The route type. *

* * @param type * The route type. * @see TransitGatewayRouteType * @return Returns a reference to this object so that method calls can be chained together. * @see TransitGatewayRouteType */ Builder type(TransitGatewayRouteType type); /** *

* The state of the route. *

* * @param state * The state of the route. * @see TransitGatewayRouteState * @return Returns a reference to this object so that method calls can be chained together. * @see TransitGatewayRouteState */ Builder state(String state); /** *

* The state of the route. *

* * @param state * The state of the route. * @see TransitGatewayRouteState * @return Returns a reference to this object so that method calls can be chained together. * @see TransitGatewayRouteState */ Builder state(TransitGatewayRouteState state); } static final class BuilderImpl implements Builder { private String destinationCidrBlock; private String prefixListId; private List transitGatewayAttachments = DefaultSdkAutoConstructList.getInstance(); private String type; private String state; private BuilderImpl() { } private BuilderImpl(TransitGatewayRoute model) { destinationCidrBlock(model.destinationCidrBlock); prefixListId(model.prefixListId); transitGatewayAttachments(model.transitGatewayAttachments); type(model.type); state(model.state); } public final String getDestinationCidrBlock() { return destinationCidrBlock; } @Override public final Builder destinationCidrBlock(String destinationCidrBlock) { this.destinationCidrBlock = destinationCidrBlock; return this; } public final void setDestinationCidrBlock(String destinationCidrBlock) { this.destinationCidrBlock = destinationCidrBlock; } public final String getPrefixListId() { return prefixListId; } @Override public final Builder prefixListId(String prefixListId) { this.prefixListId = prefixListId; return this; } public final void setPrefixListId(String prefixListId) { this.prefixListId = prefixListId; } public final Collection getTransitGatewayAttachments() { return transitGatewayAttachments != null ? transitGatewayAttachments.stream() .map(TransitGatewayRouteAttachment::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder transitGatewayAttachments(Collection transitGatewayAttachments) { this.transitGatewayAttachments = TransitGatewayRouteAttachmentListCopier.copy(transitGatewayAttachments); return this; } @Override @SafeVarargs public final Builder transitGatewayAttachments(TransitGatewayRouteAttachment... transitGatewayAttachments) { transitGatewayAttachments(Arrays.asList(transitGatewayAttachments)); return this; } @Override @SafeVarargs public final Builder transitGatewayAttachments( Consumer... transitGatewayAttachments) { transitGatewayAttachments(Stream.of(transitGatewayAttachments) .map(c -> TransitGatewayRouteAttachment.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final void setTransitGatewayAttachments( Collection transitGatewayAttachments) { this.transitGatewayAttachments = TransitGatewayRouteAttachmentListCopier.copyFromBuilder(transitGatewayAttachments); } public final String getType() { return type; } @Override public final Builder type(String type) { this.type = type; return this; } @Override public final Builder type(TransitGatewayRouteType type) { this.type(type == null ? null : type.toString()); return this; } public final void setType(String type) { this.type = type; } public final String getState() { return state; } @Override public final Builder state(String state) { this.state = state; return this; } @Override public final Builder state(TransitGatewayRouteState state) { this.state(state == null ? null : state.toString()); return this; } public final void setState(String state) { this.state = state; } @Override public TransitGatewayRoute build() { return new TransitGatewayRoute(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy