software.amazon.awssdk.services.s3.model.ListObjectsResponse 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.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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class ListObjectsResponse extends S3Response implements
ToCopyableBuilder {
private static final SdkField IS_TRUNCATED_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("IsTruncated")
.getter(getter(ListObjectsResponse::isTruncated))
.setter(setter(Builder::isTruncated))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IsTruncated")
.unmarshallLocationName("IsTruncated").build()).build();
private static final SdkField MARKER_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Marker")
.getter(getter(ListObjectsResponse::marker))
.setter(setter(Builder::marker))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Marker")
.unmarshallLocationName("Marker").build()).build();
private static final SdkField NEXT_MARKER_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("NextMarker")
.getter(getter(ListObjectsResponse::nextMarker))
.setter(setter(Builder::nextMarker))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextMarker")
.unmarshallLocationName("NextMarker").build()).build();
private static final SdkField> CONTENTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Contents")
.getter(getter(ListObjectsResponse::contents))
.setter(setter(Builder::contents))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Contents")
.unmarshallLocationName("Contents").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(S3Object::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").unmarshallLocationName("member").build()).build())
.isFlattened(true).build()).build();
private static final SdkField NAME_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Name")
.getter(getter(ListObjectsResponse::name))
.setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name")
.unmarshallLocationName("Name").build()).build();
private static final SdkField PREFIX_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Prefix")
.getter(getter(ListObjectsResponse::prefix))
.setter(setter(Builder::prefix))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Prefix")
.unmarshallLocationName("Prefix").build()).build();
private static final SdkField DELIMITER_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Delimiter")
.getter(getter(ListObjectsResponse::delimiter))
.setter(setter(Builder::delimiter))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Delimiter")
.unmarshallLocationName("Delimiter").build()).build();
private static final SdkField MAX_KEYS_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("MaxKeys")
.getter(getter(ListObjectsResponse::maxKeys))
.setter(setter(Builder::maxKeys))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxKeys")
.unmarshallLocationName("MaxKeys").build()).build();
private static final SdkField> COMMON_PREFIXES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("CommonPrefixes")
.getter(getter(ListObjectsResponse::commonPrefixes))
.setter(setter(Builder::commonPrefixes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CommonPrefixes")
.unmarshallLocationName("CommonPrefixes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(CommonPrefix::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").unmarshallLocationName("member").build()).build())
.isFlattened(true).build()).build();
private static final SdkField ENCODING_TYPE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("EncodingType")
.getter(getter(ListObjectsResponse::encodingTypeAsString))
.setter(setter(Builder::encodingType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EncodingType")
.unmarshallLocationName("EncodingType").build()).build();
private static final SdkField REQUEST_CHARGED_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("RequestCharged")
.getter(getter(ListObjectsResponse::requestChargedAsString))
.setter(setter(Builder::requestCharged))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-request-charged")
.unmarshallLocationName("x-amz-request-charged").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(IS_TRUNCATED_FIELD,
MARKER_FIELD, NEXT_MARKER_FIELD, CONTENTS_FIELD, NAME_FIELD, PREFIX_FIELD, DELIMITER_FIELD, MAX_KEYS_FIELD,
COMMON_PREFIXES_FIELD, ENCODING_TYPE_FIELD, REQUEST_CHARGED_FIELD));
private final Boolean isTruncated;
private final String marker;
private final String nextMarker;
private final List contents;
private final String name;
private final String prefix;
private final String delimiter;
private final Integer maxKeys;
private final List commonPrefixes;
private final String encodingType;
private final String requestCharged;
private ListObjectsResponse(BuilderImpl builder) {
super(builder);
this.isTruncated = builder.isTruncated;
this.marker = builder.marker;
this.nextMarker = builder.nextMarker;
this.contents = builder.contents;
this.name = builder.name;
this.prefix = builder.prefix;
this.delimiter = builder.delimiter;
this.maxKeys = builder.maxKeys;
this.commonPrefixes = builder.commonPrefixes;
this.encodingType = builder.encodingType;
this.requestCharged = builder.requestCharged;
}
/**
*
* A flag that indicates whether Amazon S3 returned all of the results that satisfied the search criteria.
*
*
* @return A flag that indicates whether Amazon S3 returned all of the results that satisfied the search criteria.
*/
public final Boolean isTruncated() {
return isTruncated;
}
/**
*
* Indicates where in the bucket listing begins. Marker is included in the response if it was sent with the request.
*
*
* @return Indicates where in the bucket listing begins. Marker is included in the response if it was sent with the
* request.
*/
public final String marker() {
return marker;
}
/**
*
* When the response is truncated (the IsTruncated
element value in the response is true
),
* you can use the key name in this field as the marker
parameter in the subsequent request to get the
* next set of objects. Amazon S3 lists objects in alphabetical order.
*
*
*
* This element is returned only if you have the delimiter
request parameter specified. If the response
* does not include the NextMarker
element and it is truncated, you can use the value of the last
* Key
element in the response as the marker
parameter in the subsequent request to get
* the next set of object keys.
*
*
*
* @return When the response is truncated (the IsTruncated
element value in the response is
* true
), you can use the key name in this field as the marker
parameter in the
* subsequent request to get the next set of objects. Amazon S3 lists objects in alphabetical order.
*
*
* This element is returned only if you have the delimiter
request parameter specified. If the
* response does not include the NextMarker
element and it is truncated, you can use the value
* of the last Key
element in the response as the marker
parameter in the
* subsequent request to get the next set of object keys.
*
*/
public final String nextMarker() {
return nextMarker;
}
/**
* For responses, this returns true if the service returned a value for the Contents 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 hasContents() {
return contents != null && !(contents instanceof SdkAutoConstructList);
}
/**
*
* Metadata about each object returned.
*
*
* 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 #hasContents} method.
*
*
* @return Metadata about each object returned.
*/
public final List contents() {
return contents;
}
/**
*
* The bucket name.
*
*
* @return The bucket name.
*/
public final String name() {
return name;
}
/**
*
* Keys that begin with the indicated prefix.
*
*
* @return Keys that begin with the indicated prefix.
*/
public final String prefix() {
return prefix;
}
/**
*
* Causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be
* rolled up into a single result element in the CommonPrefixes
collection. These rolled-up keys are
* not returned elsewhere in the response. Each rolled-up result counts as only one return against the
* MaxKeys
value.
*
*
* @return Causes keys that contain the same string between the prefix and the first occurrence of the delimiter to
* be rolled up into a single result element in the CommonPrefixes
collection. These rolled-up
* keys are not returned elsewhere in the response. Each rolled-up result counts as only one return against
* the MaxKeys
value.
*/
public final String delimiter() {
return delimiter;
}
/**
*
* The maximum number of keys returned in the response body.
*
*
* @return The maximum number of keys returned in the response body.
*/
public final Integer maxKeys() {
return maxKeys;
}
/**
* For responses, this returns true if the service returned a value for the CommonPrefixes 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 hasCommonPrefixes() {
return commonPrefixes != null && !(commonPrefixes instanceof SdkAutoConstructList);
}
/**
*
* All of the keys (up to 1,000) rolled up in a common prefix count as a single return when calculating the number
* of returns.
*
*
* A response can contain CommonPrefixes
only if you specify a delimiter.
*
*
* CommonPrefixes
contains all (if there are any) keys between Prefix
and the next
* occurrence of the string specified by the delimiter.
*
*
* CommonPrefixes
lists keys that act like subdirectories in the directory specified by
* Prefix
.
*
*
* For example, if the prefix is notes/
and the delimiter is a slash (/
), as in
* notes/summer/july
, the common prefix is notes/summer/
. All of the keys that roll up
* into a common prefix count as a single return when calculating the number of returns.
*
*
* 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 #hasCommonPrefixes} method.
*
*
* @return All of the keys (up to 1,000) rolled up in a common prefix count as a single return when calculating the
* number of returns.
*
* A response can contain CommonPrefixes
only if you specify a delimiter.
*
*
* CommonPrefixes
contains all (if there are any) keys between Prefix
and the next
* occurrence of the string specified by the delimiter.
*
*
* CommonPrefixes
lists keys that act like subdirectories in the directory specified by
* Prefix
.
*
*
* For example, if the prefix is notes/
and the delimiter is a slash (/
), as in
* notes/summer/july
, the common prefix is notes/summer/
. All of the keys that
* roll up into a common prefix count as a single return when calculating the number of returns.
*/
public final List commonPrefixes() {
return commonPrefixes;
}
/**
*
* Encoding type used by Amazon S3 to encode the object keys in the response.
* Responses are encoded only in UTF-8. An object key can contain any Unicode character. However, the XML 1.0 parser
* can't parse certain characters, such as characters with an ASCII value from 0 to 10. For characters that aren't
* supported in XML 1.0, you can add this parameter to request that Amazon S3 encode the keys in the response. For
* more information about characters to avoid in object key names, see Object key
* naming guidelines.
*
*
*
* When using the URL encoding type, non-ASCII characters that are used in an object's key name will be
* percent-encoded according to UTF-8 code values. For example, the object test_file(3).png
will appear
* as test_file%283%29.png
.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #encodingType} will
* return {@link EncodingType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #encodingTypeAsString}.
*
*
* @return Encoding type used by Amazon S3 to encode the object keys in the
* response. Responses are encoded only in UTF-8. An object key can contain any Unicode character. However,
* the XML 1.0 parser can't parse certain characters, such as characters with an ASCII value from 0 to 10.
* For characters that aren't supported in XML 1.0, you can add this parameter to request that Amazon S3
* encode the keys in the response. For more information about characters to avoid in object key names, see
*
* Object key naming guidelines.
*
* When using the URL encoding type, non-ASCII characters that are used in an object's key name will be
* percent-encoded according to UTF-8 code values. For example, the object test_file(3).png
* will appear as test_file%283%29.png
.
*
* @see EncodingType
*/
public final EncodingType encodingType() {
return EncodingType.fromValue(encodingType);
}
/**
*
* Encoding type used by Amazon S3 to encode the object keys in the response.
* Responses are encoded only in UTF-8. An object key can contain any Unicode character. However, the XML 1.0 parser
* can't parse certain characters, such as characters with an ASCII value from 0 to 10. For characters that aren't
* supported in XML 1.0, you can add this parameter to request that Amazon S3 encode the keys in the response. For
* more information about characters to avoid in object key names, see Object key
* naming guidelines.
*
*
*
* When using the URL encoding type, non-ASCII characters that are used in an object's key name will be
* percent-encoded according to UTF-8 code values. For example, the object test_file(3).png
will appear
* as test_file%283%29.png
.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #encodingType} will
* return {@link EncodingType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #encodingTypeAsString}.
*
*
* @return Encoding type used by Amazon S3 to encode the object keys in the
* response. Responses are encoded only in UTF-8. An object key can contain any Unicode character. However,
* the XML 1.0 parser can't parse certain characters, such as characters with an ASCII value from 0 to 10.
* For characters that aren't supported in XML 1.0, you can add this parameter to request that Amazon S3
* encode the keys in the response. For more information about characters to avoid in object key names, see
*
* Object key naming guidelines.
*
* When using the URL encoding type, non-ASCII characters that are used in an object's key name will be
* percent-encoded according to UTF-8 code values. For example, the object test_file(3).png
* will appear as test_file%283%29.png
.
*
* @see EncodingType
*/
public final String encodingTypeAsString() {
return encodingType;
}
/**
* Returns the value of the RequestCharged property for this object.
*
* If the service returns an enum value that is not available in the current SDK version, {@link #requestCharged}
* will return {@link RequestCharged#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #requestChargedAsString}.
*
*
* @return The value of the RequestCharged property for this object.
* @see RequestCharged
*/
public final RequestCharged requestCharged() {
return RequestCharged.fromValue(requestCharged);
}
/**
* Returns the value of the RequestCharged property for this object.
*
* If the service returns an enum value that is not available in the current SDK version, {@link #requestCharged}
* will return {@link RequestCharged#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #requestChargedAsString}.
*
*
* @return The value of the RequestCharged property for this object.
* @see RequestCharged
*/
public final String requestChargedAsString() {
return requestCharged;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(isTruncated());
hashCode = 31 * hashCode + Objects.hashCode(marker());
hashCode = 31 * hashCode + Objects.hashCode(nextMarker());
hashCode = 31 * hashCode + Objects.hashCode(hasContents() ? contents() : null);
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(prefix());
hashCode = 31 * hashCode + Objects.hashCode(delimiter());
hashCode = 31 * hashCode + Objects.hashCode(maxKeys());
hashCode = 31 * hashCode + Objects.hashCode(hasCommonPrefixes() ? commonPrefixes() : null);
hashCode = 31 * hashCode + Objects.hashCode(encodingTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(requestChargedAsString());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ListObjectsResponse)) {
return false;
}
ListObjectsResponse other = (ListObjectsResponse) obj;
return Objects.equals(isTruncated(), other.isTruncated()) && Objects.equals(marker(), other.marker())
&& Objects.equals(nextMarker(), other.nextMarker()) && hasContents() == other.hasContents()
&& Objects.equals(contents(), other.contents()) && Objects.equals(name(), other.name())
&& Objects.equals(prefix(), other.prefix()) && Objects.equals(delimiter(), other.delimiter())
&& Objects.equals(maxKeys(), other.maxKeys()) && hasCommonPrefixes() == other.hasCommonPrefixes()
&& Objects.equals(commonPrefixes(), other.commonPrefixes())
&& Objects.equals(encodingTypeAsString(), other.encodingTypeAsString())
&& Objects.equals(requestChargedAsString(), other.requestChargedAsString());
}
/**
* 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("ListObjectsResponse").add("IsTruncated", isTruncated()).add("Marker", marker())
.add("NextMarker", nextMarker()).add("Contents", hasContents() ? contents() : null).add("Name", name())
.add("Prefix", prefix()).add("Delimiter", delimiter()).add("MaxKeys", maxKeys())
.add("CommonPrefixes", hasCommonPrefixes() ? commonPrefixes() : null).add("EncodingType", encodingTypeAsString())
.add("RequestCharged", requestChargedAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "IsTruncated":
return Optional.ofNullable(clazz.cast(isTruncated()));
case "Marker":
return Optional.ofNullable(clazz.cast(marker()));
case "NextMarker":
return Optional.ofNullable(clazz.cast(nextMarker()));
case "Contents":
return Optional.ofNullable(clazz.cast(contents()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Prefix":
return Optional.ofNullable(clazz.cast(prefix()));
case "Delimiter":
return Optional.ofNullable(clazz.cast(delimiter()));
case "MaxKeys":
return Optional.ofNullable(clazz.cast(maxKeys()));
case "CommonPrefixes":
return Optional.ofNullable(clazz.cast(commonPrefixes()));
case "EncodingType":
return Optional.ofNullable(clazz.cast(encodingTypeAsString()));
case "RequestCharged":
return Optional.ofNullable(clazz.cast(requestChargedAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function