
software.amazon.awssdk.services.cloudfront.model.CacheBehavior 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.cloudfront.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.Consumer;
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;
/**
*
* A complex type that describes how CloudFront processes requests.
*
*
* You must create at least as many cache behaviors (including the default cache behavior) as you have origins if you
* want CloudFront to distribute objects from all of the origins. Each cache behavior specifies the one origin from
* which you want CloudFront to get objects. If you have two origins and only the default cache behavior, the default
* cache behavior will cause CloudFront to get objects from one of the origins, but the other origin is never used.
*
*
* For the current limit on the number of cache behaviors that you can add to a distribution, see Amazon CloudFront
* Limits in the AWS General Reference.
*
*
* If you don't want to specify any cache behaviors, include only an empty CacheBehaviors
element. Don't
* include an empty CacheBehavior
element, or CloudFront returns a MalformedXML
error.
*
*
* To delete all cache behaviors in an existing distribution, update the distribution configuration and include only an
* empty CacheBehaviors
element.
*
*
* To add, change, or remove one or more cache behaviors, update the distribution configuration and specify all of the
* cache behaviors that you want to include in the updated distribution.
*
*
* For more information about cache behaviors, see Cache Behaviors in the Amazon CloudFront Developer Guide.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CacheBehavior implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField PATH_PATTERN_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(CacheBehavior::pathPattern))
.setter(setter(Builder::pathPattern))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PathPattern")
.unmarshallLocationName("PathPattern").build()).build();
private static final SdkField TARGET_ORIGIN_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(CacheBehavior::targetOriginId))
.setter(setter(Builder::targetOriginId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetOriginId")
.unmarshallLocationName("TargetOriginId").build()).build();
private static final SdkField FORWARDED_VALUES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.getter(getter(CacheBehavior::forwardedValues))
.setter(setter(Builder::forwardedValues))
.constructor(ForwardedValues::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ForwardedValues")
.unmarshallLocationName("ForwardedValues").build()).build();
private static final SdkField TRUSTED_SIGNERS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.getter(getter(CacheBehavior::trustedSigners))
.setter(setter(Builder::trustedSigners))
.constructor(TrustedSigners::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TrustedSigners")
.unmarshallLocationName("TrustedSigners").build()).build();
private static final SdkField VIEWER_PROTOCOL_POLICY_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(CacheBehavior::viewerProtocolPolicyAsString))
.setter(setter(Builder::viewerProtocolPolicy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ViewerProtocolPolicy")
.unmarshallLocationName("ViewerProtocolPolicy").build()).build();
private static final SdkField MIN_TTL_FIELD = SdkField
. builder(MarshallingType.LONG)
.getter(getter(CacheBehavior::minTTL))
.setter(setter(Builder::minTTL))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MinTTL")
.unmarshallLocationName("MinTTL").build()).build();
private static final SdkField ALLOWED_METHODS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.getter(getter(CacheBehavior::allowedMethods))
.setter(setter(Builder::allowedMethods))
.constructor(AllowedMethods::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AllowedMethods")
.unmarshallLocationName("AllowedMethods").build()).build();
private static final SdkField SMOOTH_STREAMING_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.getter(getter(CacheBehavior::smoothStreaming))
.setter(setter(Builder::smoothStreaming))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SmoothStreaming")
.unmarshallLocationName("SmoothStreaming").build()).build();
private static final SdkField DEFAULT_TTL_FIELD = SdkField
. builder(MarshallingType.LONG)
.getter(getter(CacheBehavior::defaultTTL))
.setter(setter(Builder::defaultTTL))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DefaultTTL")
.unmarshallLocationName("DefaultTTL").build()).build();
private static final SdkField MAX_TTL_FIELD = SdkField
. builder(MarshallingType.LONG)
.getter(getter(CacheBehavior::maxTTL))
.setter(setter(Builder::maxTTL))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxTTL")
.unmarshallLocationName("MaxTTL").build()).build();
private static final SdkField COMPRESS_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.getter(getter(CacheBehavior::compress))
.setter(setter(Builder::compress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Compress")
.unmarshallLocationName("Compress").build()).build();
private static final SdkField LAMBDA_FUNCTION_ASSOCIATIONS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.getter(getter(CacheBehavior::lambdaFunctionAssociations))
.setter(setter(Builder::lambdaFunctionAssociations))
.constructor(LambdaFunctionAssociations::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LambdaFunctionAssociations")
.unmarshallLocationName("LambdaFunctionAssociations").build()).build();
private static final SdkField FIELD_LEVEL_ENCRYPTION_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(CacheBehavior::fieldLevelEncryptionId))
.setter(setter(Builder::fieldLevelEncryptionId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FieldLevelEncryptionId")
.unmarshallLocationName("FieldLevelEncryptionId").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PATH_PATTERN_FIELD,
TARGET_ORIGIN_ID_FIELD, FORWARDED_VALUES_FIELD, TRUSTED_SIGNERS_FIELD, VIEWER_PROTOCOL_POLICY_FIELD, MIN_TTL_FIELD,
ALLOWED_METHODS_FIELD, SMOOTH_STREAMING_FIELD, DEFAULT_TTL_FIELD, MAX_TTL_FIELD, COMPRESS_FIELD,
LAMBDA_FUNCTION_ASSOCIATIONS_FIELD, FIELD_LEVEL_ENCRYPTION_ID_FIELD));
private static final long serialVersionUID = 1L;
private final String pathPattern;
private final String targetOriginId;
private final ForwardedValues forwardedValues;
private final TrustedSigners trustedSigners;
private final String viewerProtocolPolicy;
private final Long minTTL;
private final AllowedMethods allowedMethods;
private final Boolean smoothStreaming;
private final Long defaultTTL;
private final Long maxTTL;
private final Boolean compress;
private final LambdaFunctionAssociations lambdaFunctionAssociations;
private final String fieldLevelEncryptionId;
private CacheBehavior(BuilderImpl builder) {
this.pathPattern = builder.pathPattern;
this.targetOriginId = builder.targetOriginId;
this.forwardedValues = builder.forwardedValues;
this.trustedSigners = builder.trustedSigners;
this.viewerProtocolPolicy = builder.viewerProtocolPolicy;
this.minTTL = builder.minTTL;
this.allowedMethods = builder.allowedMethods;
this.smoothStreaming = builder.smoothStreaming;
this.defaultTTL = builder.defaultTTL;
this.maxTTL = builder.maxTTL;
this.compress = builder.compress;
this.lambdaFunctionAssociations = builder.lambdaFunctionAssociations;
this.fieldLevelEncryptionId = builder.fieldLevelEncryptionId;
}
/**
*
* The pattern (for example, images/*.jpg
) that specifies which requests to apply the behavior to. When
* CloudFront receives a viewer request, the requested path is compared with path patterns in the order in which
* cache behaviors are listed in the distribution.
*
*
*
* You can optionally include a slash (/
) at the beginning of the path pattern. For example,
* /images/*.jpg
. CloudFront behavior is the same with or without the leading /
.
*
*
*
* The path pattern for the default cache behavior is *
and cannot be changed. If the request for an
* object does not match the path pattern for any cache behaviors, CloudFront applies the behavior in the default
* cache behavior.
*
*
* For more information, see Path Pattern in the Amazon CloudFront Developer Guide.
*
*
* @return The pattern (for example, images/*.jpg
) that specifies which requests to apply the behavior
* to. When CloudFront receives a viewer request, the requested path is compared with path patterns in the
* order in which cache behaviors are listed in the distribution.
*
* You can optionally include a slash (/
) at the beginning of the path pattern. For example,
* /images/*.jpg
. CloudFront behavior is the same with or without the leading /
.
*
*
*
* The path pattern for the default cache behavior is *
and cannot be changed. If the request
* for an object does not match the path pattern for any cache behaviors, CloudFront applies the behavior in
* the default cache behavior.
*
*
* For more information, see Path Pattern in the Amazon CloudFront Developer Guide.
*/
public String pathPattern() {
return pathPattern;
}
/**
*
* The value of ID
for the origin that you want CloudFront to route requests to when a request matches
* the path pattern either for a cache behavior or for the default cache behavior in your distribution.
*
*
* @return The value of ID
for the origin that you want CloudFront to route requests to when a request
* matches the path pattern either for a cache behavior or for the default cache behavior in your
* distribution.
*/
public String targetOriginId() {
return targetOriginId;
}
/**
*
* A complex type that specifies how CloudFront handles query strings, cookies, and HTTP headers.
*
*
* @return A complex type that specifies how CloudFront handles query strings, cookies, and HTTP headers.
*/
public ForwardedValues forwardedValues() {
return forwardedValues;
}
/**
*
* A complex type that specifies the AWS accounts, if any, that you want to allow to create signed URLs for private
* content.
*
*
* If you want to require signed URLs in requests for objects in the target origin that match the
* PathPattern
for this cache behavior, specify true
for Enabled
, and specify
* the applicable values for Quantity
and Items
. For more information, see Serving Private
* Content through CloudFront in the Amazon CloudFront Developer Guide.
*
*
* If you don't want to require signed URLs in requests for objects that match PathPattern
, specify
* false
for Enabled
and 0
for Quantity
. Omit Items
* .
*
*
* To add, change, or remove one or more trusted signers, change Enabled
to true
(if it's
* currently false
), change Quantity
as applicable, and specify all of the trusted signers
* that you want to include in the updated distribution.
*
*
* @return A complex type that specifies the AWS accounts, if any, that you want to allow to create signed URLs for
* private content.
*
* If you want to require signed URLs in requests for objects in the target origin that match the
* PathPattern
for this cache behavior, specify true
for Enabled
, and
* specify the applicable values for Quantity
and Items
. For more information, see
* Serving
* Private Content through CloudFront in the Amazon CloudFront Developer Guide.
*
*
* If you don't want to require signed URLs in requests for objects that match PathPattern
,
* specify false
for Enabled
and 0
for Quantity
. Omit
* Items
.
*
*
* To add, change, or remove one or more trusted signers, change Enabled
to true
* (if it's currently false
), change Quantity
as applicable, and specify all of
* the trusted signers that you want to include in the updated distribution.
*/
public TrustedSigners trustedSigners() {
return trustedSigners;
}
/**
*
* The protocol that viewers can use to access the files in the origin specified by TargetOriginId
when
* a request matches the path pattern in PathPattern
. You can specify the following options:
*
*
* -
*
* allow-all
: Viewers can use HTTP or HTTPS.
*
*
* -
*
* redirect-to-https
: If a viewer submits an HTTP request, CloudFront returns an HTTP status code of
* 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the
* new URL.
*
*
* -
*
* https-only
: If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403
* (Forbidden).
*
*
*
*
* For more information about requiring the HTTPS protocol, see Using an HTTPS
* Connection to Access Your Objects in the Amazon CloudFront Developer Guide.
*
*
*
* The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never
* to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that
* you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will
* return an object from the cache regardless of whether the current request protocol matches the protocol used
* previously. For more information, see Managing How Long
* Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
*
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #viewerProtocolPolicy} will return {@link ViewerProtocolPolicy#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #viewerProtocolPolicyAsString}.
*
*
* @return The protocol that viewers can use to access the files in the origin specified by
* TargetOriginId
when a request matches the path pattern in PathPattern
. You can
* specify the following options:
*
* -
*
* allow-all
: Viewers can use HTTP or HTTPS.
*
*
* -
*
* redirect-to-https
: If a viewer submits an HTTP request, CloudFront returns an HTTP status
* code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the
* request using the new URL.
*
*
* -
*
* https-only
: If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403
* (Forbidden).
*
*
*
*
* For more information about requiring the HTTPS protocol, see Using an
* HTTPS Connection to Access Your Objects in the Amazon CloudFront Developer Guide.
*
*
*
* The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is
* never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we
* recommend that you clear your objects' cache because cached objects are protocol agnostic. That means
* that an edge location will return an object from the cache regardless of whether the current request
* protocol matches the protocol used previously. For more information, see Managing How
* Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
*
* @see ViewerProtocolPolicy
*/
public ViewerProtocolPolicy viewerProtocolPolicy() {
return ViewerProtocolPolicy.fromValue(viewerProtocolPolicy);
}
/**
*
* The protocol that viewers can use to access the files in the origin specified by TargetOriginId
when
* a request matches the path pattern in PathPattern
. You can specify the following options:
*
*
* -
*
* allow-all
: Viewers can use HTTP or HTTPS.
*
*
* -
*
* redirect-to-https
: If a viewer submits an HTTP request, CloudFront returns an HTTP status code of
* 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the
* new URL.
*
*
* -
*
* https-only
: If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403
* (Forbidden).
*
*
*
*
* For more information about requiring the HTTPS protocol, see Using an HTTPS
* Connection to Access Your Objects in the Amazon CloudFront Developer Guide.
*
*
*
* The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never
* to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that
* you clear your objects' cache because cached objects are protocol agnostic. That means that an edge location will
* return an object from the cache regardless of whether the current request protocol matches the protocol used
* previously. For more information, see Managing How Long
* Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
*
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #viewerProtocolPolicy} will return {@link ViewerProtocolPolicy#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #viewerProtocolPolicyAsString}.
*
*
* @return The protocol that viewers can use to access the files in the origin specified by
* TargetOriginId
when a request matches the path pattern in PathPattern
. You can
* specify the following options:
*
* -
*
* allow-all
: Viewers can use HTTP or HTTPS.
*
*
* -
*
* redirect-to-https
: If a viewer submits an HTTP request, CloudFront returns an HTTP status
* code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the
* request using the new URL.
*
*
* -
*
* https-only
: If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403
* (Forbidden).
*
*
*
*
* For more information about requiring the HTTPS protocol, see Using an
* HTTPS Connection to Access Your Objects in the Amazon CloudFront Developer Guide.
*
*
*
* The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is
* never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we
* recommend that you clear your objects' cache because cached objects are protocol agnostic. That means
* that an edge location will return an object from the cache regardless of whether the current request
* protocol matches the protocol used previously. For more information, see Managing How
* Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
*
* @see ViewerProtocolPolicy
*/
public String viewerProtocolPolicyAsString() {
return viewerProtocolPolicy;
}
/**
*
* The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another
* request to your origin to determine whether the object has been updated. For more information, see Managing How Long
* Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
*
*
* You must specify 0
for MinTTL
if you configure CloudFront to forward all headers to
* your origin (under Headers
, if you specify 1
for Quantity
and
* *
for Name
).
*
*
* @return The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards
* another request to your origin to determine whether the object has been updated. For more information,
* see
* Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer
* Guide.
*
* You must specify 0
for MinTTL
if you configure CloudFront to forward all
* headers to your origin (under Headers
, if you specify 1
for
* Quantity
and *
for Name
).
*/
public Long minTTL() {
return minTTL;
}
/**
* Returns the value of the AllowedMethods property for this object.
*
* @return The value of the AllowedMethods property for this object.
*/
public AllowedMethods allowedMethods() {
return allowedMethods;
}
/**
*
* Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the origin
* that is associated with this cache behavior. If so, specify true
; if not, specify false
* . If you specify true
for SmoothStreaming
, you can still distribute other content using
* this cache behavior if the content matches the value of PathPattern
.
*
*
* @return Indicates whether you want to distribute media files in the Microsoft Smooth Streaming format using the
* origin that is associated with this cache behavior. If so, specify true
; if not, specify
* false
. If you specify true
for SmoothStreaming
, you can still
* distribute other content using this cache behavior if the content matches the value of
* PathPattern
.
*/
public Boolean smoothStreaming() {
return smoothStreaming;
}
/**
*
* The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another
* request to your origin to determine whether the object has been updated. The value that you specify applies only
* when your origin does not add HTTP headers such as Cache-Control max-age
,
* Cache-Control s-maxage
, and Expires
to objects. For more information, see Managing How Long
* Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
*
*
* @return The default amount of time that you want objects to stay in CloudFront caches before CloudFront forwards
* another request to your origin to determine whether the object has been updated. The value that you
* specify applies only when your origin does not add HTTP headers such as
* Cache-Control max-age
, Cache-Control s-maxage
, and Expires
to
* objects. For more information, see Managing How
* Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
*/
public Long defaultTTL() {
return defaultTTL;
}
/**
*
* The maximum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards another
* request to your origin to determine whether the object has been updated. The value that you specify applies only
* when your origin adds HTTP headers such as Cache-Control max-age
,
* Cache-Control s-maxage
, and Expires
to objects. For more information, see Managing How Long
* Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
*
*
* @return The maximum amount of time that you want objects to stay in CloudFront caches before CloudFront forwards
* another request to your origin to determine whether the object has been updated. The value that you
* specify applies only when your origin adds HTTP headers such as Cache-Control max-age
,
* Cache-Control s-maxage
, and Expires
to objects. For more information, see Managing How
* Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
*/
public Long maxTTL() {
return maxTTL;
}
/**
*
* Whether you want CloudFront to automatically compress certain files for this cache behavior. If so, specify true;
* if not, specify false. For more information, see Serving
* Compressed Files in the Amazon CloudFront Developer Guide.
*
*
* @return Whether you want CloudFront to automatically compress certain files for this cache behavior. If so,
* specify true; if not, specify false. For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide.
*/
public Boolean compress() {
return compress;
}
/**
*
* A complex type that contains zero or more Lambda function associations for a cache behavior.
*
*
* @return A complex type that contains zero or more Lambda function associations for a cache behavior.
*/
public LambdaFunctionAssociations lambdaFunctionAssociations() {
return lambdaFunctionAssociations;
}
/**
*
* The value of ID
for the field-level encryption configuration that you want CloudFront to use for
* encrypting specific fields of data for a cache behavior or for the default cache behavior in your distribution.
*
*
* @return The value of ID
for the field-level encryption configuration that you want CloudFront to use
* for encrypting specific fields of data for a cache behavior or for the default cache behavior in your
* distribution.
*/
public String fieldLevelEncryptionId() {
return fieldLevelEncryptionId;
}
@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(pathPattern());
hashCode = 31 * hashCode + Objects.hashCode(targetOriginId());
hashCode = 31 * hashCode + Objects.hashCode(forwardedValues());
hashCode = 31 * hashCode + Objects.hashCode(trustedSigners());
hashCode = 31 * hashCode + Objects.hashCode(viewerProtocolPolicyAsString());
hashCode = 31 * hashCode + Objects.hashCode(minTTL());
hashCode = 31 * hashCode + Objects.hashCode(allowedMethods());
hashCode = 31 * hashCode + Objects.hashCode(smoothStreaming());
hashCode = 31 * hashCode + Objects.hashCode(defaultTTL());
hashCode = 31 * hashCode + Objects.hashCode(maxTTL());
hashCode = 31 * hashCode + Objects.hashCode(compress());
hashCode = 31 * hashCode + Objects.hashCode(lambdaFunctionAssociations());
hashCode = 31 * hashCode + Objects.hashCode(fieldLevelEncryptionId());
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 CacheBehavior)) {
return false;
}
CacheBehavior other = (CacheBehavior) obj;
return Objects.equals(pathPattern(), other.pathPattern()) && Objects.equals(targetOriginId(), other.targetOriginId())
&& Objects.equals(forwardedValues(), other.forwardedValues())
&& Objects.equals(trustedSigners(), other.trustedSigners())
&& Objects.equals(viewerProtocolPolicyAsString(), other.viewerProtocolPolicyAsString())
&& Objects.equals(minTTL(), other.minTTL()) && Objects.equals(allowedMethods(), other.allowedMethods())
&& Objects.equals(smoothStreaming(), other.smoothStreaming()) && Objects.equals(defaultTTL(), other.defaultTTL())
&& Objects.equals(maxTTL(), other.maxTTL()) && Objects.equals(compress(), other.compress())
&& Objects.equals(lambdaFunctionAssociations(), other.lambdaFunctionAssociations())
&& Objects.equals(fieldLevelEncryptionId(), other.fieldLevelEncryptionId());
}
/**
* 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("CacheBehavior").add("PathPattern", pathPattern()).add("TargetOriginId", targetOriginId())
.add("ForwardedValues", forwardedValues()).add("TrustedSigners", trustedSigners())
.add("ViewerProtocolPolicy", viewerProtocolPolicyAsString()).add("MinTTL", minTTL())
.add("AllowedMethods", allowedMethods()).add("SmoothStreaming", smoothStreaming())
.add("DefaultTTL", defaultTTL()).add("MaxTTL", maxTTL()).add("Compress", compress())
.add("LambdaFunctionAssociations", lambdaFunctionAssociations())
.add("FieldLevelEncryptionId", fieldLevelEncryptionId()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "PathPattern":
return Optional.ofNullable(clazz.cast(pathPattern()));
case "TargetOriginId":
return Optional.ofNullable(clazz.cast(targetOriginId()));
case "ForwardedValues":
return Optional.ofNullable(clazz.cast(forwardedValues()));
case "TrustedSigners":
return Optional.ofNullable(clazz.cast(trustedSigners()));
case "ViewerProtocolPolicy":
return Optional.ofNullable(clazz.cast(viewerProtocolPolicyAsString()));
case "MinTTL":
return Optional.ofNullable(clazz.cast(minTTL()));
case "AllowedMethods":
return Optional.ofNullable(clazz.cast(allowedMethods()));
case "SmoothStreaming":
return Optional.ofNullable(clazz.cast(smoothStreaming()));
case "DefaultTTL":
return Optional.ofNullable(clazz.cast(defaultTTL()));
case "MaxTTL":
return Optional.ofNullable(clazz.cast(maxTTL()));
case "Compress":
return Optional.ofNullable(clazz.cast(compress()));
case "LambdaFunctionAssociations":
return Optional.ofNullable(clazz.cast(lambdaFunctionAssociations()));
case "FieldLevelEncryptionId":
return Optional.ofNullable(clazz.cast(fieldLevelEncryptionId()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function