
software.amazon.awssdk.services.s3control.model.StorageLensGroupAndOperator 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.s3control.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;
/**
*
* A logical operator that allows multiple filter conditions to be joined for more complex comparisons of Storage Lens
* group data.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class StorageLensGroupAndOperator implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField> MATCH_ANY_PREFIX_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("MatchAnyPrefix")
.getter(getter(StorageLensGroupAndOperator::matchAnyPrefix))
.setter(setter(Builder::matchAnyPrefix))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MatchAnyPrefix")
.unmarshallLocationName("MatchAnyPrefix").build(),
ListTrait
.builder()
.memberLocationName("Prefix")
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Prefix").unmarshallLocationName("Prefix").build()).build())
.build()).build();
private static final SdkField> MATCH_ANY_SUFFIX_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("MatchAnySuffix")
.getter(getter(StorageLensGroupAndOperator::matchAnySuffix))
.setter(setter(Builder::matchAnySuffix))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MatchAnySuffix")
.unmarshallLocationName("MatchAnySuffix").build(),
ListTrait
.builder()
.memberLocationName("Suffix")
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Suffix").unmarshallLocationName("Suffix").build()).build())
.build()).build();
private static final SdkField> MATCH_ANY_TAG_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("MatchAnyTag")
.getter(getter(StorageLensGroupAndOperator::matchAnyTag))
.setter(setter(Builder::matchAnyTag))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MatchAnyTag")
.unmarshallLocationName("MatchAnyTag").build(),
ListTrait
.builder()
.memberLocationName("Tag")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(S3Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Tag").unmarshallLocationName("Tag").build()).build()).build())
.build();
private static final SdkField MATCH_OBJECT_AGE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("MatchObjectAge")
.getter(getter(StorageLensGroupAndOperator::matchObjectAge))
.setter(setter(Builder::matchObjectAge))
.constructor(MatchObjectAge::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MatchObjectAge")
.unmarshallLocationName("MatchObjectAge").build()).build();
private static final SdkField MATCH_OBJECT_SIZE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("MatchObjectSize")
.getter(getter(StorageLensGroupAndOperator::matchObjectSize))
.setter(setter(Builder::matchObjectSize))
.constructor(MatchObjectSize::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MatchObjectSize")
.unmarshallLocationName("MatchObjectSize").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(MATCH_ANY_PREFIX_FIELD,
MATCH_ANY_SUFFIX_FIELD, MATCH_ANY_TAG_FIELD, MATCH_OBJECT_AGE_FIELD, MATCH_OBJECT_SIZE_FIELD));
private static final long serialVersionUID = 1L;
private final List matchAnyPrefix;
private final List matchAnySuffix;
private final List matchAnyTag;
private final MatchObjectAge matchObjectAge;
private final MatchObjectSize matchObjectSize;
private StorageLensGroupAndOperator(BuilderImpl builder) {
this.matchAnyPrefix = builder.matchAnyPrefix;
this.matchAnySuffix = builder.matchAnySuffix;
this.matchAnyTag = builder.matchAnyTag;
this.matchObjectAge = builder.matchObjectAge;
this.matchObjectSize = builder.matchObjectSize;
}
/**
* For responses, this returns true if the service returned a value for the MatchAnyPrefix 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 hasMatchAnyPrefix() {
return matchAnyPrefix != null && !(matchAnyPrefix instanceof SdkAutoConstructList);
}
/**
*
* Contains a list of prefixes. At least one prefix must be specified. Up to 10 prefixes are allowed.
*
*
* 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 #hasMatchAnyPrefix} method.
*
*
* @return Contains a list of prefixes. At least one prefix must be specified. Up to 10 prefixes are allowed.
*/
public final List matchAnyPrefix() {
return matchAnyPrefix;
}
/**
* For responses, this returns true if the service returned a value for the MatchAnySuffix 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 hasMatchAnySuffix() {
return matchAnySuffix != null && !(matchAnySuffix instanceof SdkAutoConstructList);
}
/**
*
* Contains a list of suffixes. At least one suffix must be specified. Up to 10 suffixes are allowed.
*
*
* 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 #hasMatchAnySuffix} method.
*
*
* @return Contains a list of suffixes. At least one suffix must be specified. Up to 10 suffixes are allowed.
*/
public final List matchAnySuffix() {
return matchAnySuffix;
}
/**
* For responses, this returns true if the service returned a value for the MatchAnyTag 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 hasMatchAnyTag() {
return matchAnyTag != null && !(matchAnyTag instanceof SdkAutoConstructList);
}
/**
*
* Contains the list of object tags. At least one object tag must be specified. Up to 10 object tags are allowed.
*
*
* 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 #hasMatchAnyTag} method.
*
*
* @return Contains the list of object tags. At least one object tag must be specified. Up to 10 object tags are
* allowed.
*/
public final List matchAnyTag() {
return matchAnyTag;
}
/**
*
* Contains DaysGreaterThan
and DaysLessThan
to define the object age range (minimum and
* maximum number of days).
*
*
* @return Contains DaysGreaterThan
and DaysLessThan
to define the object age range
* (minimum and maximum number of days).
*/
public final MatchObjectAge matchObjectAge() {
return matchObjectAge;
}
/**
*
* Contains BytesGreaterThan
and BytesLessThan
to define the object size range (minimum
* and maximum number of Bytes).
*
*
* @return Contains BytesGreaterThan
and BytesLessThan
to define the object size range
* (minimum and maximum number of Bytes).
*/
public final MatchObjectSize matchObjectSize() {
return matchObjectSize;
}
@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(hasMatchAnyPrefix() ? matchAnyPrefix() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasMatchAnySuffix() ? matchAnySuffix() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasMatchAnyTag() ? matchAnyTag() : null);
hashCode = 31 * hashCode + Objects.hashCode(matchObjectAge());
hashCode = 31 * hashCode + Objects.hashCode(matchObjectSize());
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 StorageLensGroupAndOperator)) {
return false;
}
StorageLensGroupAndOperator other = (StorageLensGroupAndOperator) obj;
return hasMatchAnyPrefix() == other.hasMatchAnyPrefix() && Objects.equals(matchAnyPrefix(), other.matchAnyPrefix())
&& hasMatchAnySuffix() == other.hasMatchAnySuffix() && Objects.equals(matchAnySuffix(), other.matchAnySuffix())
&& hasMatchAnyTag() == other.hasMatchAnyTag() && Objects.equals(matchAnyTag(), other.matchAnyTag())
&& Objects.equals(matchObjectAge(), other.matchObjectAge())
&& Objects.equals(matchObjectSize(), other.matchObjectSize());
}
/**
* 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("StorageLensGroupAndOperator")
.add("MatchAnyPrefix", hasMatchAnyPrefix() ? matchAnyPrefix() : null)
.add("MatchAnySuffix", hasMatchAnySuffix() ? matchAnySuffix() : null)
.add("MatchAnyTag", hasMatchAnyTag() ? matchAnyTag() : null).add("MatchObjectAge", matchObjectAge())
.add("MatchObjectSize", matchObjectSize()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "MatchAnyPrefix":
return Optional.ofNullable(clazz.cast(matchAnyPrefix()));
case "MatchAnySuffix":
return Optional.ofNullable(clazz.cast(matchAnySuffix()));
case "MatchAnyTag":
return Optional.ofNullable(clazz.cast(matchAnyTag()));
case "MatchObjectAge":
return Optional.ofNullable(clazz.cast(matchObjectAge()));
case "MatchObjectSize":
return Optional.ofNullable(clazz.cast(matchObjectSize()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function