software.amazon.awssdk.services.s3.model.S3Location Maven / Gradle / Ivy
Show all versions of s3 Show documentation
/*
* 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.s3.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.traits.RequiredTrait;
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 an Amazon S3 location that will receive the results of the restore request.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class S3Location implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField BUCKET_NAME_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("BucketName")
.getter(getter(S3Location::bucketName))
.setter(setter(Builder::bucketName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BucketName")
.unmarshallLocationName("BucketName").build(), RequiredTrait.create()).build();
private static final SdkField PREFIX_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Prefix")
.getter(getter(S3Location::prefix))
.setter(setter(Builder::prefix))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Prefix")
.unmarshallLocationName("Prefix").build(), RequiredTrait.create()).build();
private static final SdkField ENCRYPTION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("Encryption")
.getter(getter(S3Location::encryption))
.setter(setter(Builder::encryption))
.constructor(Encryption::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Encryption")
.unmarshallLocationName("Encryption").build()).build();
private static final SdkField CANNED_ACL_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("CannedACL")
.getter(getter(S3Location::cannedACLAsString))
.setter(setter(Builder::cannedACL))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CannedACL")
.unmarshallLocationName("CannedACL").build()).build();
private static final SdkField> ACCESS_CONTROL_LIST_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("AccessControlList")
.getter(getter(S3Location::accessControlList))
.setter(setter(Builder::accessControlList))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccessControlList")
.unmarshallLocationName("AccessControlList").build(),
ListTrait
.builder()
.memberLocationName("Grant")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Grant::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Grant").unmarshallLocationName("Grant").build()).build())
.build()).build();
private static final SdkField TAGGING_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("Tagging")
.getter(getter(S3Location::tagging))
.setter(setter(Builder::tagging))
.constructor(Tagging::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tagging")
.unmarshallLocationName("Tagging").build()).build();
private static final SdkField> USER_METADATA_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("UserMetadata")
.getter(getter(S3Location::userMetadata))
.setter(setter(Builder::userMetadata))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UserMetadata")
.unmarshallLocationName("UserMetadata").build(),
ListTrait
.builder()
.memberLocationName("MetadataEntry")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(MetadataEntry::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("MetadataEntry").unmarshallLocationName("MetadataEntry")
.build()).build()).build()).build();
private static final SdkField STORAGE_CLASS_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("StorageClass")
.getter(getter(S3Location::storageClassAsString))
.setter(setter(Builder::storageClass))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StorageClass")
.unmarshallLocationName("StorageClass").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BUCKET_NAME_FIELD,
PREFIX_FIELD, ENCRYPTION_FIELD, CANNED_ACL_FIELD, ACCESS_CONTROL_LIST_FIELD, TAGGING_FIELD, USER_METADATA_FIELD,
STORAGE_CLASS_FIELD));
private static final long serialVersionUID = 1L;
private final String bucketName;
private final String prefix;
private final Encryption encryption;
private final String cannedACL;
private final List accessControlList;
private final Tagging tagging;
private final List userMetadata;
private final String storageClass;
private S3Location(BuilderImpl builder) {
this.bucketName = builder.bucketName;
this.prefix = builder.prefix;
this.encryption = builder.encryption;
this.cannedACL = builder.cannedACL;
this.accessControlList = builder.accessControlList;
this.tagging = builder.tagging;
this.userMetadata = builder.userMetadata;
this.storageClass = builder.storageClass;
}
/**
*
* The name of the bucket where the restore results will be placed.
*
*
* @return The name of the bucket where the restore results will be placed.
*/
public final String bucketName() {
return bucketName;
}
/**
*
* The prefix that is prepended to the restore results for this request.
*
*
* @return The prefix that is prepended to the restore results for this request.
*/
public final String prefix() {
return prefix;
}
/**
* Returns the value of the Encryption property for this object.
*
* @return The value of the Encryption property for this object.
*/
public final Encryption encryption() {
return encryption;
}
/**
*
* The canned ACL to apply to the restore results.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #cannedACL} will
* return {@link ObjectCannedACL#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #cannedACLAsString}.
*
*
* @return The canned ACL to apply to the restore results.
* @see ObjectCannedACL
*/
public final ObjectCannedACL cannedACL() {
return ObjectCannedACL.fromValue(cannedACL);
}
/**
*
* The canned ACL to apply to the restore results.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #cannedACL} will
* return {@link ObjectCannedACL#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #cannedACLAsString}.
*
*
* @return The canned ACL to apply to the restore results.
* @see ObjectCannedACL
*/
public final String cannedACLAsString() {
return cannedACL;
}
/**
* For responses, this returns true if the service returned a value for the AccessControlList 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 hasAccessControlList() {
return accessControlList != null && !(accessControlList instanceof SdkAutoConstructList);
}
/**
*
* A list of grants that control access to the staged results.
*
*
* 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 #hasAccessControlList} method.
*
*
* @return A list of grants that control access to the staged results.
*/
public final List accessControlList() {
return accessControlList;
}
/**
*
* The tag-set that is applied to the restore results.
*
*
* @return The tag-set that is applied to the restore results.
*/
public final Tagging tagging() {
return tagging;
}
/**
* For responses, this returns true if the service returned a value for the UserMetadata 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 hasUserMetadata() {
return userMetadata != null && !(userMetadata instanceof SdkAutoConstructList);
}
/**
*
* A list of metadata to store with the restore results in S3.
*
*
* 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 #hasUserMetadata} method.
*
*
* @return A list of metadata to store with the restore results in S3.
*/
public final List userMetadata() {
return userMetadata;
}
/**
*
* The class of storage used to store the restore results.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #storageClass} will
* return {@link StorageClass#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #storageClassAsString}.
*
*
* @return The class of storage used to store the restore results.
* @see StorageClass
*/
public final StorageClass storageClass() {
return StorageClass.fromValue(storageClass);
}
/**
*
* The class of storage used to store the restore results.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #storageClass} will
* return {@link StorageClass#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #storageClassAsString}.
*
*
* @return The class of storage used to store the restore results.
* @see StorageClass
*/
public final String storageClassAsString() {
return storageClass;
}
@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(bucketName());
hashCode = 31 * hashCode + Objects.hashCode(prefix());
hashCode = 31 * hashCode + Objects.hashCode(encryption());
hashCode = 31 * hashCode + Objects.hashCode(cannedACLAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasAccessControlList() ? accessControlList() : null);
hashCode = 31 * hashCode + Objects.hashCode(tagging());
hashCode = 31 * hashCode + Objects.hashCode(hasUserMetadata() ? userMetadata() : null);
hashCode = 31 * hashCode + Objects.hashCode(storageClassAsString());
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 S3Location)) {
return false;
}
S3Location other = (S3Location) obj;
return Objects.equals(bucketName(), other.bucketName()) && Objects.equals(prefix(), other.prefix())
&& Objects.equals(encryption(), other.encryption())
&& Objects.equals(cannedACLAsString(), other.cannedACLAsString())
&& hasAccessControlList() == other.hasAccessControlList()
&& Objects.equals(accessControlList(), other.accessControlList()) && Objects.equals(tagging(), other.tagging())
&& hasUserMetadata() == other.hasUserMetadata() && Objects.equals(userMetadata(), other.userMetadata())
&& Objects.equals(storageClassAsString(), other.storageClassAsString());
}
/**
* 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("S3Location").add("BucketName", bucketName()).add("Prefix", prefix())
.add("Encryption", encryption()).add("CannedACL", cannedACLAsString())
.add("AccessControlList", hasAccessControlList() ? accessControlList() : null).add("Tagging", tagging())
.add("UserMetadata", hasUserMetadata() ? userMetadata() : null).add("StorageClass", storageClassAsString())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "BucketName":
return Optional.ofNullable(clazz.cast(bucketName()));
case "Prefix":
return Optional.ofNullable(clazz.cast(prefix()));
case "Encryption":
return Optional.ofNullable(clazz.cast(encryption()));
case "CannedACL":
return Optional.ofNullable(clazz.cast(cannedACLAsString()));
case "AccessControlList":
return Optional.ofNullable(clazz.cast(accessControlList()));
case "Tagging":
return Optional.ofNullable(clazz.cast(tagging()));
case "UserMetadata":
return Optional.ofNullable(clazz.cast(userMetadata()));
case "StorageClass":
return Optional.ofNullable(clazz.cast(storageClassAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function