
software.amazon.awssdk.services.sqs.model.MessageSystemAttributeValue 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.sqs.model;
import java.io.Serializable;
import java.nio.ByteBuffer;
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.Function;
import java.util.stream.Collectors;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkBytes;
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;
/**
*
* The user-specified message system attribute value. For string data types, the Value
attribute has the
* same restrictions on the content as the message body. For more information, see SendMessage.
*
*
* Name
, type
, value
and the message body must not be empty or null.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class MessageSystemAttributeValue implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField STRING_VALUE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StringValue").getter(getter(MessageSystemAttributeValue::stringValue))
.setter(setter(Builder::stringValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StringValue").build()).build();
private static final SdkField BINARY_VALUE_FIELD = SdkField. builder(MarshallingType.SDK_BYTES)
.memberName("BinaryValue").getter(getter(MessageSystemAttributeValue::binaryValue))
.setter(setter(Builder::binaryValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BinaryValue").build()).build();
private static final SdkField> STRING_LIST_VALUES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("StringListValues")
.getter(getter(MessageSystemAttributeValue::stringListValues))
.setter(setter(Builder::stringListValues))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StringListValues").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).isFlattened(true).build()).build();
private static final SdkField> BINARY_LIST_VALUES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("BinaryListValues")
.getter(getter(MessageSystemAttributeValue::binaryListValues))
.setter(setter(Builder::binaryListValues))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BinaryListValues").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_BYTES)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).isFlattened(true).build()).build();
private static final SdkField DATA_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DataType").getter(getter(MessageSystemAttributeValue::dataType)).setter(setter(Builder::dataType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DataType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STRING_VALUE_FIELD,
BINARY_VALUE_FIELD, STRING_LIST_VALUES_FIELD, BINARY_LIST_VALUES_FIELD, DATA_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String stringValue;
private final SdkBytes binaryValue;
private final List stringListValues;
private final List binaryListValues;
private final String dataType;
private MessageSystemAttributeValue(BuilderImpl builder) {
this.stringValue = builder.stringValue;
this.binaryValue = builder.binaryValue;
this.stringListValues = builder.stringListValues;
this.binaryListValues = builder.binaryListValues;
this.dataType = builder.dataType;
}
/**
*
* Strings are Unicode with UTF-8 binary encoding. For a list of code values, see ASCII Printable Characters.
*
*
* @return Strings are Unicode with UTF-8 binary encoding. For a list of code values, see ASCII Printable Characters.
*/
public final String stringValue() {
return stringValue;
}
/**
*
* Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.
*
*
* @return Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.
*/
public final SdkBytes binaryValue() {
return binaryValue;
}
/**
* For responses, this returns true if the service returned a value for the StringListValues 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 hasStringListValues() {
return stringListValues != null && !(stringListValues instanceof SdkAutoConstructList);
}
/**
*
* Not implemented. Reserved for future use.
*
*
* 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 #hasStringListValues} method.
*
*
* @return Not implemented. Reserved for future use.
*/
public final List stringListValues() {
return stringListValues;
}
/**
* For responses, this returns true if the service returned a value for the BinaryListValues 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 hasBinaryListValues() {
return binaryListValues != null && !(binaryListValues instanceof SdkAutoConstructList);
}
/**
*
* Not implemented. Reserved for future use.
*
*
* 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 #hasBinaryListValues} method.
*
*
* @return Not implemented. Reserved for future use.
*/
public final List binaryListValues() {
return binaryListValues;
}
/**
*
* Amazon SQS supports the following logical data types: String
, Number
, and
* Binary
. For the Number
data type, you must use StringValue
.
*
*
* You can also append custom labels. For more information, see Amazon SQS Message Attributes in the Amazon SQS Developer Guide.
*
*
* @return Amazon SQS supports the following logical data types: String
, Number
, and
* Binary
. For the Number
data type, you must use StringValue
.
*
* You can also append custom labels. For more information, see Amazon SQS Message Attributes in the Amazon SQS Developer Guide.
*/
public final String dataType() {
return dataType;
}
@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(stringValue());
hashCode = 31 * hashCode + Objects.hashCode(binaryValue());
hashCode = 31 * hashCode + Objects.hashCode(hasStringListValues() ? stringListValues() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasBinaryListValues() ? binaryListValues() : null);
hashCode = 31 * hashCode + Objects.hashCode(dataType());
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 MessageSystemAttributeValue)) {
return false;
}
MessageSystemAttributeValue other = (MessageSystemAttributeValue) obj;
return Objects.equals(stringValue(), other.stringValue()) && Objects.equals(binaryValue(), other.binaryValue())
&& hasStringListValues() == other.hasStringListValues()
&& Objects.equals(stringListValues(), other.stringListValues())
&& hasBinaryListValues() == other.hasBinaryListValues()
&& Objects.equals(binaryListValues(), other.binaryListValues()) && Objects.equals(dataType(), other.dataType());
}
/**
* 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("MessageSystemAttributeValue").add("StringValue", stringValue())
.add("BinaryValue", binaryValue()).add("StringListValues", hasStringListValues() ? stringListValues() : null)
.add("BinaryListValues", hasBinaryListValues() ? binaryListValues() : null).add("DataType", dataType()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "StringValue":
return Optional.ofNullable(clazz.cast(stringValue()));
case "BinaryValue":
return Optional.ofNullable(clazz.cast(binaryValue()));
case "StringListValues":
return Optional.ofNullable(clazz.cast(stringListValues()));
case "BinaryListValues":
return Optional.ofNullable(clazz.cast(binaryListValues()));
case "DataType":
return Optional.ofNullable(clazz.cast(dataType()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* You can also append custom labels. For more information, see Amazon SQS Message Attributes in the Amazon SQS Developer Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder dataType(String dataType);
}
static final class BuilderImpl implements Builder {
private String stringValue;
private SdkBytes binaryValue;
private List stringListValues = DefaultSdkAutoConstructList.getInstance();
private List binaryListValues = DefaultSdkAutoConstructList.getInstance();
private String dataType;
private BuilderImpl() {
}
private BuilderImpl(MessageSystemAttributeValue model) {
stringValue(model.stringValue);
binaryValue(model.binaryValue);
stringListValues(model.stringListValues);
binaryListValues(model.binaryListValues);
dataType(model.dataType);
}
public final String getStringValue() {
return stringValue;
}
public final void setStringValue(String stringValue) {
this.stringValue = stringValue;
}
@Override
public final Builder stringValue(String stringValue) {
this.stringValue = stringValue;
return this;
}
public final ByteBuffer getBinaryValue() {
return binaryValue == null ? null : binaryValue.asByteBuffer();
}
public final void setBinaryValue(ByteBuffer binaryValue) {
binaryValue(binaryValue == null ? null : SdkBytes.fromByteBuffer(binaryValue));
}
@Override
public final Builder binaryValue(SdkBytes binaryValue) {
this.binaryValue = binaryValue;
return this;
}
public final Collection getStringListValues() {
if (stringListValues instanceof SdkAutoConstructList) {
return null;
}
return stringListValues;
}
public final void setStringListValues(Collection stringListValues) {
this.stringListValues = StringListCopier.copy(stringListValues);
}
@Override
public final Builder stringListValues(Collection stringListValues) {
this.stringListValues = StringListCopier.copy(stringListValues);
return this;
}
@Override
@SafeVarargs
public final Builder stringListValues(String... stringListValues) {
stringListValues(Arrays.asList(stringListValues));
return this;
}
public final List getBinaryListValues() {
if (binaryListValues instanceof SdkAutoConstructList) {
return null;
}
return binaryListValues == null ? null : binaryListValues.stream().map(SdkBytes::asByteBuffer)
.collect(Collectors.toList());
}
public final void setBinaryListValues(Collection binaryListValues) {
binaryListValues(binaryListValues == null ? null : binaryListValues.stream().map(SdkBytes::fromByteBuffer)
.collect(Collectors.toList()));
}
@Override
public final Builder binaryListValues(Collection binaryListValues) {
this.binaryListValues = BinaryListCopier.copy(binaryListValues);
return this;
}
@Override
@SafeVarargs
public final Builder binaryListValues(SdkBytes... binaryListValues) {
binaryListValues(Arrays.asList(binaryListValues));
return this;
}
public final String getDataType() {
return dataType;
}
public final void setDataType(String dataType) {
this.dataType = dataType;
}
@Override
public final Builder dataType(String dataType) {
this.dataType = dataType;
return this;
}
@Override
public MessageSystemAttributeValue build() {
return new MessageSystemAttributeValue(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}