
software.amazon.awssdk.services.macie2.model.ClassificationResult 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.macie2.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;
/**
*
* Provides the details of a sensitive data finding, including the types, number of occurrences, and locations of the
* sensitive data that was detected.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ClassificationResult implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ADDITIONAL_OCCURRENCES_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("additionalOccurrences").getter(getter(ClassificationResult::additionalOccurrences))
.setter(setter(Builder::additionalOccurrences))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("additionalOccurrences").build())
.build();
private static final SdkField CUSTOM_DATA_IDENTIFIERS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("customDataIdentifiers")
.getter(getter(ClassificationResult::customDataIdentifiers)).setter(setter(Builder::customDataIdentifiers))
.constructor(CustomDataIdentifiers::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("customDataIdentifiers").build())
.build();
private static final SdkField MIME_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("mimeType").getter(getter(ClassificationResult::mimeType)).setter(setter(Builder::mimeType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("mimeType").build()).build();
private static final SdkField> SENSITIVE_DATA_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("sensitiveData")
.getter(getter(ClassificationResult::sensitiveData))
.setter(setter(Builder::sensitiveData))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sensitiveData").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(SensitiveDataItem::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField SIZE_CLASSIFIED_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("sizeClassified").getter(getter(ClassificationResult::sizeClassified))
.setter(setter(Builder::sizeClassified))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sizeClassified").build()).build();
private static final SdkField STATUS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("status")
.getter(getter(ClassificationResult::status)).setter(setter(Builder::status))
.constructor(ClassificationResultStatus::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ADDITIONAL_OCCURRENCES_FIELD,
CUSTOM_DATA_IDENTIFIERS_FIELD, MIME_TYPE_FIELD, SENSITIVE_DATA_FIELD, SIZE_CLASSIFIED_FIELD, STATUS_FIELD));
private static final long serialVersionUID = 1L;
private final Boolean additionalOccurrences;
private final CustomDataIdentifiers customDataIdentifiers;
private final String mimeType;
private final List sensitiveData;
private final Long sizeClassified;
private final ClassificationResultStatus status;
private ClassificationResult(BuilderImpl builder) {
this.additionalOccurrences = builder.additionalOccurrences;
this.customDataIdentifiers = builder.customDataIdentifiers;
this.mimeType = builder.mimeType;
this.sensitiveData = builder.sensitiveData;
this.sizeClassified = builder.sizeClassified;
this.status = builder.status;
}
/**
*
* Specifies whether Amazon Macie detected additional occurrences of sensitive data in the S3 object. A finding
* includes location data for a maximum of 15 occurrences of sensitive data.
*
*
* This value can help you determine whether to investigate additional occurrences of sensitive data in an object.
* You can do this by referring to the corresponding sensitive data discovery result for the finding
* (ClassificationDetails.detailedResultsLocation).
*
*
* @return Specifies whether Amazon Macie detected additional occurrences of sensitive data in the S3 object. A
* finding includes location data for a maximum of 15 occurrences of sensitive data.
*
* This value can help you determine whether to investigate additional occurrences of sensitive data in an
* object. You can do this by referring to the corresponding sensitive data discovery result for the finding
* (ClassificationDetails.detailedResultsLocation).
*/
public final Boolean additionalOccurrences() {
return additionalOccurrences;
}
/**
*
* The custom data identifiers that detected the sensitive data and the number of occurrences of the data that they
* detected.
*
*
* @return The custom data identifiers that detected the sensitive data and the number of occurrences of the data
* that they detected.
*/
public final CustomDataIdentifiers customDataIdentifiers() {
return customDataIdentifiers;
}
/**
*
* The type of content, as a MIME type, that the finding applies to. For example, application/gzip, for a GNU Gzip
* compressed archive file, or application/pdf, for an Adobe Portable Document Format file.
*
*
* @return The type of content, as a MIME type, that the finding applies to. For example, application/gzip, for a
* GNU Gzip compressed archive file, or application/pdf, for an Adobe Portable Document Format file.
*/
public final String mimeType() {
return mimeType;
}
/**
* For responses, this returns true if the service returned a value for the SensitiveData 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 hasSensitiveData() {
return sensitiveData != null && !(sensitiveData instanceof SdkAutoConstructList);
}
/**
*
* The category, types, and number of occurrences of the sensitive data that produced the finding.
*
*
* 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 #hasSensitiveData} method.
*
*
* @return The category, types, and number of occurrences of the sensitive data that produced the finding.
*/
public final List sensitiveData() {
return sensitiveData;
}
/**
*
* The total size, in bytes, of the data that the finding applies to.
*
*
* @return The total size, in bytes, of the data that the finding applies to.
*/
public final Long sizeClassified() {
return sizeClassified;
}
/**
*
* The status of the finding.
*
*
* @return The status of the finding.
*/
public final ClassificationResultStatus status() {
return status;
}
@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(additionalOccurrences());
hashCode = 31 * hashCode + Objects.hashCode(customDataIdentifiers());
hashCode = 31 * hashCode + Objects.hashCode(mimeType());
hashCode = 31 * hashCode + Objects.hashCode(hasSensitiveData() ? sensitiveData() : null);
hashCode = 31 * hashCode + Objects.hashCode(sizeClassified());
hashCode = 31 * hashCode + Objects.hashCode(status());
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 ClassificationResult)) {
return false;
}
ClassificationResult other = (ClassificationResult) obj;
return Objects.equals(additionalOccurrences(), other.additionalOccurrences())
&& Objects.equals(customDataIdentifiers(), other.customDataIdentifiers())
&& Objects.equals(mimeType(), other.mimeType()) && hasSensitiveData() == other.hasSensitiveData()
&& Objects.equals(sensitiveData(), other.sensitiveData())
&& Objects.equals(sizeClassified(), other.sizeClassified()) && Objects.equals(status(), other.status());
}
/**
* 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("ClassificationResult").add("AdditionalOccurrences", additionalOccurrences())
.add("CustomDataIdentifiers", customDataIdentifiers()).add("MimeType", mimeType())
.add("SensitiveData", hasSensitiveData() ? sensitiveData() : null).add("SizeClassified", sizeClassified())
.add("Status", status()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "additionalOccurrences":
return Optional.ofNullable(clazz.cast(additionalOccurrences()));
case "customDataIdentifiers":
return Optional.ofNullable(clazz.cast(customDataIdentifiers()));
case "mimeType":
return Optional.ofNullable(clazz.cast(mimeType()));
case "sensitiveData":
return Optional.ofNullable(clazz.cast(sensitiveData()));
case "sizeClassified":
return Optional.ofNullable(clazz.cast(sizeClassified()));
case "status":
return Optional.ofNullable(clazz.cast(status()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function