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

software.amazon.awssdk.services.appmesh.model.HttpGatewayRouteMatch 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.appmesh.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;

/**
 * 

* An object that represents the criteria for determining a request match. *

*/ @Generated("software.amazon.awssdk:codegen") public final class HttpGatewayRouteMatch implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> HEADERS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("headers") .getter(getter(HttpGatewayRouteMatch::headers)) .setter(setter(Builder::headers)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("headers").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(HttpGatewayRouteHeader::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField HOSTNAME_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("hostname") .getter(getter(HttpGatewayRouteMatch::hostname)).setter(setter(Builder::hostname)) .constructor(GatewayRouteHostnameMatch::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("hostname").build()).build(); private static final SdkField METHOD_FIELD = SdkField. builder(MarshallingType.STRING).memberName("method") .getter(getter(HttpGatewayRouteMatch::methodAsString)).setter(setter(Builder::method)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("method").build()).build(); private static final SdkField PATH_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("path").getter(getter(HttpGatewayRouteMatch::path)).setter(setter(Builder::path)) .constructor(HttpPathMatch::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("path").build()).build(); private static final SdkField PORT_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("port") .getter(getter(HttpGatewayRouteMatch::port)).setter(setter(Builder::port)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("port").build()).build(); private static final SdkField PREFIX_FIELD = SdkField. builder(MarshallingType.STRING).memberName("prefix") .getter(getter(HttpGatewayRouteMatch::prefix)).setter(setter(Builder::prefix)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("prefix").build()).build(); private static final SdkField> QUERY_PARAMETERS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("queryParameters") .getter(getter(HttpGatewayRouteMatch::queryParameters)) .setter(setter(Builder::queryParameters)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("queryParameters").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(HttpQueryParameter::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(HEADERS_FIELD, HOSTNAME_FIELD, METHOD_FIELD, PATH_FIELD, PORT_FIELD, PREFIX_FIELD, QUERY_PARAMETERS_FIELD)); private static final long serialVersionUID = 1L; private final List headers; private final GatewayRouteHostnameMatch hostname; private final String method; private final HttpPathMatch path; private final Integer port; private final String prefix; private final List queryParameters; private HttpGatewayRouteMatch(BuilderImpl builder) { this.headers = builder.headers; this.hostname = builder.hostname; this.method = builder.method; this.path = builder.path; this.port = builder.port; this.prefix = builder.prefix; this.queryParameters = builder.queryParameters; } /** * For responses, this returns true if the service returned a value for the Headers 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 hasHeaders() { return headers != null && !(headers instanceof SdkAutoConstructList); } /** *

* The client request headers to match on. *

*

* 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 #hasHeaders} method. *

* * @return The client request headers to match on. */ public final List headers() { return headers; } /** *

* The host name to match on. *

* * @return The host name to match on. */ public final GatewayRouteHostnameMatch hostname() { return hostname; } /** *

* The method to match on. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #method} will * return {@link HttpMethod#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #methodAsString}. *

* * @return The method to match on. * @see HttpMethod */ public final HttpMethod method() { return HttpMethod.fromValue(method); } /** *

* The method to match on. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #method} will * return {@link HttpMethod#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #methodAsString}. *

* * @return The method to match on. * @see HttpMethod */ public final String methodAsString() { return method; } /** *

* The path to match on. *

* * @return The path to match on. */ public final HttpPathMatch path() { return path; } /** *

* The port number to match on. *

* * @return The port number to match on. */ public final Integer port() { return port; } /** *

* Specifies the path to match requests with. This parameter must always start with /, which by itself * matches all requests to the virtual service name. You can also match for path-based routing of requests. For * example, if your virtual service name is my-service.local and you want the route to match requests * to my-service.local/metrics, your prefix should be /metrics. *

* * @return Specifies the path to match requests with. This parameter must always start with /, which by * itself matches all requests to the virtual service name. You can also match for path-based routing of * requests. For example, if your virtual service name is my-service.local and you want the * route to match requests to my-service.local/metrics, your prefix should be * /metrics. */ public final String prefix() { return prefix; } /** * For responses, this returns true if the service returned a value for the QueryParameters 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 hasQueryParameters() { return queryParameters != null && !(queryParameters instanceof SdkAutoConstructList); } /** *

* The query parameter to match on. *

*

* 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 #hasQueryParameters} method. *

* * @return The query parameter to match on. */ public final List queryParameters() { return queryParameters; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(hasHeaders() ? headers() : null); hashCode = 31 * hashCode + Objects.hashCode(hostname()); hashCode = 31 * hashCode + Objects.hashCode(methodAsString()); hashCode = 31 * hashCode + Objects.hashCode(path()); hashCode = 31 * hashCode + Objects.hashCode(port()); hashCode = 31 * hashCode + Objects.hashCode(prefix()); hashCode = 31 * hashCode + Objects.hashCode(hasQueryParameters() ? queryParameters() : 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 HttpGatewayRouteMatch)) { return false; } HttpGatewayRouteMatch other = (HttpGatewayRouteMatch) obj; return hasHeaders() == other.hasHeaders() && Objects.equals(headers(), other.headers()) && Objects.equals(hostname(), other.hostname()) && Objects.equals(methodAsString(), other.methodAsString()) && Objects.equals(path(), other.path()) && Objects.equals(port(), other.port()) && Objects.equals(prefix(), other.prefix()) && hasQueryParameters() == other.hasQueryParameters() && Objects.equals(queryParameters(), other.queryParameters()); } /** * 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("HttpGatewayRouteMatch").add("Headers", hasHeaders() ? headers() : null) .add("Hostname", hostname()).add("Method", methodAsString()).add("Path", path()).add("Port", port()) .add("Prefix", prefix()).add("QueryParameters", hasQueryParameters() ? queryParameters() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "headers": return Optional.ofNullable(clazz.cast(headers())); case "hostname": return Optional.ofNullable(clazz.cast(hostname())); case "method": return Optional.ofNullable(clazz.cast(methodAsString())); case "path": return Optional.ofNullable(clazz.cast(path())); case "port": return Optional.ofNullable(clazz.cast(port())); case "prefix": return Optional.ofNullable(clazz.cast(prefix())); case "queryParameters": return Optional.ofNullable(clazz.cast(queryParameters())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((HttpGatewayRouteMatch) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The client request headers to match on. *

* * @param headers * The client request headers to match on. * @return Returns a reference to this object so that method calls can be chained together. */ Builder headers(Collection headers); /** *

* The client request headers to match on. *

* * @param headers * The client request headers to match on. * @return Returns a reference to this object so that method calls can be chained together. */ Builder headers(HttpGatewayRouteHeader... headers); /** *

* The client request headers to match on. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.appmesh.model.HttpGatewayRouteHeader.Builder} avoiding the need to * create one manually via * {@link software.amazon.awssdk.services.appmesh.model.HttpGatewayRouteHeader#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.appmesh.model.HttpGatewayRouteHeader.Builder#build()} is called * immediately and its result is passed to {@link #headers(List)}. * * @param headers * a consumer that will call methods on * {@link software.amazon.awssdk.services.appmesh.model.HttpGatewayRouteHeader.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #headers(java.util.Collection) */ Builder headers(Consumer... headers); /** *

* The host name to match on. *

* * @param hostname * The host name to match on. * @return Returns a reference to this object so that method calls can be chained together. */ Builder hostname(GatewayRouteHostnameMatch hostname); /** *

* The host name to match on. *

* This is a convenience method that creates an instance of the {@link GatewayRouteHostnameMatch.Builder} * avoiding the need to create one manually via {@link GatewayRouteHostnameMatch#builder()}. * *

* When the {@link Consumer} completes, {@link GatewayRouteHostnameMatch.Builder#build()} is called immediately * and its result is passed to {@link #hostname(GatewayRouteHostnameMatch)}. * * @param hostname * a consumer that will call methods on {@link GatewayRouteHostnameMatch.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #hostname(GatewayRouteHostnameMatch) */ default Builder hostname(Consumer hostname) { return hostname(GatewayRouteHostnameMatch.builder().applyMutation(hostname).build()); } /** *

* The method to match on. *

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

* The method to match on. *

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

* The path to match on. *

* * @param path * The path to match on. * @return Returns a reference to this object so that method calls can be chained together. */ Builder path(HttpPathMatch path); /** *

* The path to match on. *

* This is a convenience method that creates an instance of the {@link HttpPathMatch.Builder} avoiding the need * to create one manually via {@link HttpPathMatch#builder()}. * *

* When the {@link Consumer} completes, {@link HttpPathMatch.Builder#build()} is called immediately and its * result is passed to {@link #path(HttpPathMatch)}. * * @param path * a consumer that will call methods on {@link HttpPathMatch.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #path(HttpPathMatch) */ default Builder path(Consumer path) { return path(HttpPathMatch.builder().applyMutation(path).build()); } /** *

* The port number to match on. *

* * @param port * The port number to match on. * @return Returns a reference to this object so that method calls can be chained together. */ Builder port(Integer port); /** *

* Specifies the path to match requests with. This parameter must always start with /, which by * itself matches all requests to the virtual service name. You can also match for path-based routing of * requests. For example, if your virtual service name is my-service.local and you want the route * to match requests to my-service.local/metrics, your prefix should be /metrics. *

* * @param prefix * Specifies the path to match requests with. This parameter must always start with /, which * by itself matches all requests to the virtual service name. You can also match for path-based routing * of requests. For example, if your virtual service name is my-service.local and you want * the route to match requests to my-service.local/metrics, your prefix should be * /metrics. * @return Returns a reference to this object so that method calls can be chained together. */ Builder prefix(String prefix); /** *

* The query parameter to match on. *

* * @param queryParameters * The query parameter to match on. * @return Returns a reference to this object so that method calls can be chained together. */ Builder queryParameters(Collection queryParameters); /** *

* The query parameter to match on. *

* * @param queryParameters * The query parameter to match on. * @return Returns a reference to this object so that method calls can be chained together. */ Builder queryParameters(HttpQueryParameter... queryParameters); /** *

* The query parameter to match on. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.appmesh.model.HttpQueryParameter.Builder} avoiding the need to create * one manually via {@link software.amazon.awssdk.services.appmesh.model.HttpQueryParameter#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.appmesh.model.HttpQueryParameter.Builder#build()} is called * immediately and its result is passed to {@link #queryParameters(List)}. * * @param queryParameters * a consumer that will call methods on * {@link software.amazon.awssdk.services.appmesh.model.HttpQueryParameter.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #queryParameters(java.util.Collection) */ Builder queryParameters(Consumer... queryParameters); } static final class BuilderImpl implements Builder { private List headers = DefaultSdkAutoConstructList.getInstance(); private GatewayRouteHostnameMatch hostname; private String method; private HttpPathMatch path; private Integer port; private String prefix; private List queryParameters = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(HttpGatewayRouteMatch model) { headers(model.headers); hostname(model.hostname); method(model.method); path(model.path); port(model.port); prefix(model.prefix); queryParameters(model.queryParameters); } public final List getHeaders() { List result = HttpGatewayRouteHeadersCopier.copyToBuilder(this.headers); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setHeaders(Collection headers) { this.headers = HttpGatewayRouteHeadersCopier.copyFromBuilder(headers); } @Override public final Builder headers(Collection headers) { this.headers = HttpGatewayRouteHeadersCopier.copy(headers); return this; } @Override @SafeVarargs public final Builder headers(HttpGatewayRouteHeader... headers) { headers(Arrays.asList(headers)); return this; } @Override @SafeVarargs public final Builder headers(Consumer... headers) { headers(Stream.of(headers).map(c -> HttpGatewayRouteHeader.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final GatewayRouteHostnameMatch.Builder getHostname() { return hostname != null ? hostname.toBuilder() : null; } public final void setHostname(GatewayRouteHostnameMatch.BuilderImpl hostname) { this.hostname = hostname != null ? hostname.build() : null; } @Override public final Builder hostname(GatewayRouteHostnameMatch hostname) { this.hostname = hostname; return this; } public final String getMethod() { return method; } public final void setMethod(String method) { this.method = method; } @Override public final Builder method(String method) { this.method = method; return this; } @Override public final Builder method(HttpMethod method) { this.method(method == null ? null : method.toString()); return this; } public final HttpPathMatch.Builder getPath() { return path != null ? path.toBuilder() : null; } public final void setPath(HttpPathMatch.BuilderImpl path) { this.path = path != null ? path.build() : null; } @Override public final Builder path(HttpPathMatch path) { this.path = path; return this; } public final Integer getPort() { return port; } public final void setPort(Integer port) { this.port = port; } @Override public final Builder port(Integer port) { this.port = port; return this; } public final String getPrefix() { return prefix; } public final void setPrefix(String prefix) { this.prefix = prefix; } @Override public final Builder prefix(String prefix) { this.prefix = prefix; return this; } public final List getQueryParameters() { List result = HttpQueryParametersCopier.copyToBuilder(this.queryParameters); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setQueryParameters(Collection queryParameters) { this.queryParameters = HttpQueryParametersCopier.copyFromBuilder(queryParameters); } @Override public final Builder queryParameters(Collection queryParameters) { this.queryParameters = HttpQueryParametersCopier.copy(queryParameters); return this; } @Override @SafeVarargs public final Builder queryParameters(HttpQueryParameter... queryParameters) { queryParameters(Arrays.asList(queryParameters)); return this; } @Override @SafeVarargs public final Builder queryParameters(Consumer... queryParameters) { queryParameters(Stream.of(queryParameters).map(c -> HttpQueryParameter.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } @Override public HttpGatewayRouteMatch build() { return new HttpGatewayRouteMatch(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy