All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.iottwinmaker.model.DataValue Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Io T Twin Maker module holds the client classes that are used for communicating with Io T Twin Maker.

There is a newer version: 2.29.20
Show newest version
/*
 * 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.iottwinmaker.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
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.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* An object that specifies a value for a property. *

*/ @Generated("software.amazon.awssdk:codegen") public final class DataValue implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField BOOLEAN_VALUE_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .memberName("booleanValue").getter(getter(DataValue::booleanValue)).setter(setter(Builder::booleanValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("booleanValue").build()).build(); private static final SdkField DOUBLE_VALUE_FIELD = SdkField. builder(MarshallingType.DOUBLE) .memberName("doubleValue").getter(getter(DataValue::doubleValue)).setter(setter(Builder::doubleValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("doubleValue").build()).build(); private static final SdkField INTEGER_VALUE_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("integerValue").getter(getter(DataValue::integerValue)).setter(setter(Builder::integerValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("integerValue").build()).build(); private static final SdkField LONG_VALUE_FIELD = SdkField. builder(MarshallingType.LONG).memberName("longValue") .getter(getter(DataValue::longValue)).setter(setter(Builder::longValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("longValue").build()).build(); private static final SdkField STRING_VALUE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("stringValue").getter(getter(DataValue::stringValue)).setter(setter(Builder::stringValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stringValue").build()).build(); private static final SdkField> LIST_VALUE_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("listValue") .getter(getter(DataValue::listValue)) .setter(setter(Builder::listValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("listValue").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(DataValue::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField> MAP_VALUE_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("mapValue") .getter(getter(DataValue::mapValue)) .setter(setter(Builder::mapValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("mapValue").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(DataValue::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField RELATIONSHIP_VALUE_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("relationshipValue") .getter(getter(DataValue::relationshipValue)).setter(setter(Builder::relationshipValue)) .constructor(RelationshipValue::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("relationshipValue").build()).build(); private static final SdkField EXPRESSION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("expression").getter(getter(DataValue::expression)).setter(setter(Builder::expression)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("expression").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BOOLEAN_VALUE_FIELD, DOUBLE_VALUE_FIELD, INTEGER_VALUE_FIELD, LONG_VALUE_FIELD, STRING_VALUE_FIELD, LIST_VALUE_FIELD, MAP_VALUE_FIELD, RELATIONSHIP_VALUE_FIELD, EXPRESSION_FIELD)); private static final long serialVersionUID = 1L; private final Boolean booleanValue; private final Double doubleValue; private final Integer integerValue; private final Long longValue; private final String stringValue; private final List listValue; private final Map mapValue; private final RelationshipValue relationshipValue; private final String expression; private DataValue(BuilderImpl builder) { this.booleanValue = builder.booleanValue; this.doubleValue = builder.doubleValue; this.integerValue = builder.integerValue; this.longValue = builder.longValue; this.stringValue = builder.stringValue; this.listValue = builder.listValue; this.mapValue = builder.mapValue; this.relationshipValue = builder.relationshipValue; this.expression = builder.expression; } /** *

* A Boolean value. *

* * @return A Boolean value. */ public final Boolean booleanValue() { return booleanValue; } /** *

* A double value. *

* * @return A double value. */ public final Double doubleValue() { return doubleValue; } /** *

* An integer value. *

* * @return An integer value. */ public final Integer integerValue() { return integerValue; } /** *

* A long value. *

* * @return A long value. */ public final Long longValue() { return longValue; } /** *

* A string value. *

* * @return A string value. */ public final String stringValue() { return stringValue; } /** * For responses, this returns true if the service returned a value for the ListValue 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 hasListValue() { return listValue != null && !(listValue instanceof SdkAutoConstructList); } /** *

* A list of multiple values. *

*

* 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 #hasListValue} method. *

* * @return A list of multiple values. */ public final List listValue() { return listValue; } /** * For responses, this returns true if the service returned a value for the MapValue 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 hasMapValue() { return mapValue != null && !(mapValue instanceof SdkAutoConstructMap); } /** *

* An object that maps strings to multiple DataValue objects. *

*

* 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 #hasMapValue} method. *

* * @return An object that maps strings to multiple DataValue objects. */ public final Map mapValue() { return mapValue; } /** *

* A value that relates a component to another component. *

* * @return A value that relates a component to another component. */ public final RelationshipValue relationshipValue() { return relationshipValue; } /** *

* An expression that produces the value. *

* * @return An expression that produces the value. */ public final String expression() { return expression; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(booleanValue()); hashCode = 31 * hashCode + Objects.hashCode(doubleValue()); hashCode = 31 * hashCode + Objects.hashCode(integerValue()); hashCode = 31 * hashCode + Objects.hashCode(longValue()); hashCode = 31 * hashCode + Objects.hashCode(stringValue()); hashCode = 31 * hashCode + Objects.hashCode(hasListValue() ? listValue() : null); hashCode = 31 * hashCode + Objects.hashCode(hasMapValue() ? mapValue() : null); hashCode = 31 * hashCode + Objects.hashCode(relationshipValue()); hashCode = 31 * hashCode + Objects.hashCode(expression()); 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 DataValue)) { return false; } DataValue other = (DataValue) obj; return Objects.equals(booleanValue(), other.booleanValue()) && Objects.equals(doubleValue(), other.doubleValue()) && Objects.equals(integerValue(), other.integerValue()) && Objects.equals(longValue(), other.longValue()) && Objects.equals(stringValue(), other.stringValue()) && hasListValue() == other.hasListValue() && Objects.equals(listValue(), other.listValue()) && hasMapValue() == other.hasMapValue() && Objects.equals(mapValue(), other.mapValue()) && Objects.equals(relationshipValue(), other.relationshipValue()) && Objects.equals(expression(), other.expression()); } /** * 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("DataValue").add("BooleanValue", booleanValue()).add("DoubleValue", doubleValue()) .add("IntegerValue", integerValue()).add("LongValue", longValue()).add("StringValue", stringValue()) .add("ListValue", hasListValue() ? listValue() : null).add("MapValue", hasMapValue() ? mapValue() : null) .add("RelationshipValue", relationshipValue()).add("Expression", expression()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "booleanValue": return Optional.ofNullable(clazz.cast(booleanValue())); case "doubleValue": return Optional.ofNullable(clazz.cast(doubleValue())); case "integerValue": return Optional.ofNullable(clazz.cast(integerValue())); case "longValue": return Optional.ofNullable(clazz.cast(longValue())); case "stringValue": return Optional.ofNullable(clazz.cast(stringValue())); case "listValue": return Optional.ofNullable(clazz.cast(listValue())); case "mapValue": return Optional.ofNullable(clazz.cast(mapValue())); case "relationshipValue": return Optional.ofNullable(clazz.cast(relationshipValue())); case "expression": return Optional.ofNullable(clazz.cast(expression())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((DataValue) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* A Boolean value. *

* * @param booleanValue * A Boolean value. * @return Returns a reference to this object so that method calls can be chained together. */ Builder booleanValue(Boolean booleanValue); /** *

* A double value. *

* * @param doubleValue * A double value. * @return Returns a reference to this object so that method calls can be chained together. */ Builder doubleValue(Double doubleValue); /** *

* An integer value. *

* * @param integerValue * An integer value. * @return Returns a reference to this object so that method calls can be chained together. */ Builder integerValue(Integer integerValue); /** *

* A long value. *

* * @param longValue * A long value. * @return Returns a reference to this object so that method calls can be chained together. */ Builder longValue(Long longValue); /** *

* A string value. *

* * @param stringValue * A string value. * @return Returns a reference to this object so that method calls can be chained together. */ Builder stringValue(String stringValue); /** *

* A list of multiple values. *

* * @param listValue * A list of multiple values. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listValue(Collection listValue); /** *

* A list of multiple values. *

* * @param listValue * A list of multiple values. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listValue(DataValue... listValue); /** *

* A list of multiple values. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.iottwinmaker.model.DataValue.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.iottwinmaker.model.DataValue#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.iottwinmaker.model.DataValue.Builder#build()} is called immediately * and its result is passed to {@link #listValue(List)}. * * @param listValue * a consumer that will call methods on * {@link software.amazon.awssdk.services.iottwinmaker.model.DataValue.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #listValue(java.util.Collection) */ Builder listValue(Consumer... listValue); /** *

* An object that maps strings to multiple DataValue objects. *

* * @param mapValue * An object that maps strings to multiple DataValue objects. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapValue(Map mapValue); /** *

* A value that relates a component to another component. *

* * @param relationshipValue * A value that relates a component to another component. * @return Returns a reference to this object so that method calls can be chained together. */ Builder relationshipValue(RelationshipValue relationshipValue); /** *

* A value that relates a component to another component. *

* This is a convenience method that creates an instance of the {@link RelationshipValue.Builder} avoiding the * need to create one manually via {@link RelationshipValue#builder()}. * *

* When the {@link Consumer} completes, {@link RelationshipValue.Builder#build()} is called immediately and its * result is passed to {@link #relationshipValue(RelationshipValue)}. * * @param relationshipValue * a consumer that will call methods on {@link RelationshipValue.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #relationshipValue(RelationshipValue) */ default Builder relationshipValue(Consumer relationshipValue) { return relationshipValue(RelationshipValue.builder().applyMutation(relationshipValue).build()); } /** *

* An expression that produces the value. *

* * @param expression * An expression that produces the value. * @return Returns a reference to this object so that method calls can be chained together. */ Builder expression(String expression); } static final class BuilderImpl implements Builder { private Boolean booleanValue; private Double doubleValue; private Integer integerValue; private Long longValue; private String stringValue; private List listValue = DefaultSdkAutoConstructList.getInstance(); private Map mapValue = DefaultSdkAutoConstructMap.getInstance(); private RelationshipValue relationshipValue; private String expression; private BuilderImpl() { } private BuilderImpl(DataValue model) { booleanValue(model.booleanValue); doubleValue(model.doubleValue); integerValue(model.integerValue); longValue(model.longValue); stringValue(model.stringValue); listValue(model.listValue); mapValue(model.mapValue); relationshipValue(model.relationshipValue); expression(model.expression); } public final Boolean getBooleanValue() { return booleanValue; } public final void setBooleanValue(Boolean booleanValue) { this.booleanValue = booleanValue; } @Override public final Builder booleanValue(Boolean booleanValue) { this.booleanValue = booleanValue; return this; } public final Double getDoubleValue() { return doubleValue; } public final void setDoubleValue(Double doubleValue) { this.doubleValue = doubleValue; } @Override public final Builder doubleValue(Double doubleValue) { this.doubleValue = doubleValue; return this; } public final Integer getIntegerValue() { return integerValue; } public final void setIntegerValue(Integer integerValue) { this.integerValue = integerValue; } @Override public final Builder integerValue(Integer integerValue) { this.integerValue = integerValue; return this; } public final Long getLongValue() { return longValue; } public final void setLongValue(Long longValue) { this.longValue = longValue; } @Override public final Builder longValue(Long longValue) { this.longValue = longValue; return this; } 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 List getListValue() { List result = DataValueListCopier.copyToBuilder(this.listValue); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setListValue(Collection listValue) { this.listValue = DataValueListCopier.copyFromBuilder(listValue); } @Override public final Builder listValue(Collection listValue) { this.listValue = DataValueListCopier.copy(listValue); return this; } @Override @SafeVarargs public final Builder listValue(DataValue... listValue) { listValue(Arrays.asList(listValue)); return this; } @Override @SafeVarargs public final Builder listValue(Consumer... listValue) { listValue(Stream.of(listValue).map(c -> DataValue.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final Map getMapValue() { Map result = DataValueMapCopier.copyToBuilder(this.mapValue); if (result instanceof SdkAutoConstructMap) { return null; } return result; } public final void setMapValue(Map mapValue) { this.mapValue = DataValueMapCopier.copyFromBuilder(mapValue); } @Override public final Builder mapValue(Map mapValue) { this.mapValue = DataValueMapCopier.copy(mapValue); return this; } public final RelationshipValue.Builder getRelationshipValue() { return relationshipValue != null ? relationshipValue.toBuilder() : null; } public final void setRelationshipValue(RelationshipValue.BuilderImpl relationshipValue) { this.relationshipValue = relationshipValue != null ? relationshipValue.build() : null; } @Override public final Builder relationshipValue(RelationshipValue relationshipValue) { this.relationshipValue = relationshipValue; return this; } public final String getExpression() { return expression; } public final void setExpression(String expression) { this.expression = expression; } @Override public final Builder expression(String expression) { this.expression = expression; return this; } @Override public DataValue build() { return new DataValue(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy