
software.amazon.awssdk.services.cloudfront.model.EncryptionEntity 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;
/**
*
* Complex data type for field-level encryption profiles that includes the encryption key and field pattern
* specifications.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class EncryptionEntity implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField PUBLIC_KEY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("PublicKeyId")
.getter(getter(EncryptionEntity::publicKeyId))
.setter(setter(Builder::publicKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PublicKeyId")
.unmarshallLocationName("PublicKeyId").build()).build();
private static final SdkField PROVIDER_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ProviderId")
.getter(getter(EncryptionEntity::providerId))
.setter(setter(Builder::providerId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ProviderId")
.unmarshallLocationName("ProviderId").build()).build();
private static final SdkField FIELD_PATTERNS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("FieldPatterns")
.getter(getter(EncryptionEntity::fieldPatterns))
.setter(setter(Builder::fieldPatterns))
.constructor(FieldPatterns::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FieldPatterns")
.unmarshallLocationName("FieldPatterns").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PUBLIC_KEY_ID_FIELD,
PROVIDER_ID_FIELD, FIELD_PATTERNS_FIELD));
private static final long serialVersionUID = 1L;
private final String publicKeyId;
private final String providerId;
private final FieldPatterns fieldPatterns;
private EncryptionEntity(BuilderImpl builder) {
this.publicKeyId = builder.publicKeyId;
this.providerId = builder.providerId;
this.fieldPatterns = builder.fieldPatterns;
}
/**
*
* The public key associated with a set of field-level encryption patterns, to be used when encrypting the fields
* that match the patterns.
*
*
* @return The public key associated with a set of field-level encryption patterns, to be used when encrypting the
* fields that match the patterns.
*/
public final String publicKeyId() {
return publicKeyId;
}
/**
*
* The provider associated with the public key being used for encryption. This value must also be provided with the
* private key for applications to be able to decrypt data.
*
*
* @return The provider associated with the public key being used for encryption. This value must also be provided
* with the private key for applications to be able to decrypt data.
*/
public final String providerId() {
return providerId;
}
/**
*
* Field patterns in a field-level encryption content type profile specify the fields that you want to be encrypted.
* You can provide the full field name, or any beginning characters followed by a wildcard (*). You can't overlap
* field patterns. For example, you can't have both ABC* and AB*. Note that field patterns are case-sensitive.
*
*
* @return Field patterns in a field-level encryption content type profile specify the fields that you want to be
* encrypted. You can provide the full field name, or any beginning characters followed by a wildcard (*).
* You can't overlap field patterns. For example, you can't have both ABC* and AB*. Note that field patterns
* are case-sensitive.
*/
public final FieldPatterns fieldPatterns() {
return fieldPatterns;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(publicKeyId());
hashCode = 31 * hashCode + Objects.hashCode(providerId());
hashCode = 31 * hashCode + Objects.hashCode(fieldPatterns());
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 EncryptionEntity)) {
return false;
}
EncryptionEntity other = (EncryptionEntity) obj;
return Objects.equals(publicKeyId(), other.publicKeyId()) && Objects.equals(providerId(), other.providerId())
&& Objects.equals(fieldPatterns(), other.fieldPatterns());
}
/**
* 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("EncryptionEntity").add("PublicKeyId", publicKeyId()).add("ProviderId", providerId())
.add("FieldPatterns", fieldPatterns()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "PublicKeyId":
return Optional.ofNullable(clazz.cast(publicKeyId()));
case "ProviderId":
return Optional.ofNullable(clazz.cast(providerId()));
case "FieldPatterns":
return Optional.ofNullable(clazz.cast(fieldPatterns()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function