software.amazon.awssdk.services.cloudformation.model.PropertyDifference Maven / Gradle / Ivy
Show all versions of cloudformation 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.cloudformation.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
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.Function;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Information about a resource property whose actual value differs from its expected value, as defined in the stack
* template and any values specified as template parameters. These will be present only for resources whose
* StackResourceDriftStatus
is MODIFIED
. For more information, see Detect unmanaged
* configuration changes to stacks and resources with drift detection.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PropertyDifference implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField PROPERTY_PATH_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PropertyPath").getter(getter(PropertyDifference::propertyPath)).setter(setter(Builder::propertyPath))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PropertyPath").build()).build();
private static final SdkField EXPECTED_VALUE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ExpectedValue").getter(getter(PropertyDifference::expectedValue)).setter(setter(Builder::expectedValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExpectedValue").build()).build();
private static final SdkField ACTUAL_VALUE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ActualValue").getter(getter(PropertyDifference::actualValue)).setter(setter(Builder::actualValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActualValue").build()).build();
private static final SdkField DIFFERENCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DifferenceType").getter(getter(PropertyDifference::differenceTypeAsString))
.setter(setter(Builder::differenceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DifferenceType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PROPERTY_PATH_FIELD,
EXPECTED_VALUE_FIELD, ACTUAL_VALUE_FIELD, DIFFERENCE_TYPE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("PropertyPath", PROPERTY_PATH_FIELD);
put("ExpectedValue", EXPECTED_VALUE_FIELD);
put("ActualValue", ACTUAL_VALUE_FIELD);
put("DifferenceType", DIFFERENCE_TYPE_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String propertyPath;
private final String expectedValue;
private final String actualValue;
private final String differenceType;
private PropertyDifference(BuilderImpl builder) {
this.propertyPath = builder.propertyPath;
this.expectedValue = builder.expectedValue;
this.actualValue = builder.actualValue;
this.differenceType = builder.differenceType;
}
/**
*
* The fully-qualified path to the resource property.
*
*
* @return The fully-qualified path to the resource property.
*/
public final String propertyPath() {
return propertyPath;
}
/**
*
* The expected property value of the resource property, as defined in the stack template and any values specified
* as template parameters.
*
*
* @return The expected property value of the resource property, as defined in the stack template and any values
* specified as template parameters.
*/
public final String expectedValue() {
return expectedValue;
}
/**
*
* The actual property value of the resource property.
*
*
* @return The actual property value of the resource property.
*/
public final String actualValue() {
return actualValue;
}
/**
*
* The type of property difference.
*
*
* -
*
* ADD
: A value has been added to a resource property that's an array or list data type.
*
*
* -
*
* REMOVE
: The property has been removed from the current resource configuration.
*
*
* -
*
* NOT_EQUAL
: The current property value differs from its expected value (as defined in the stack
* template and any values specified as template parameters).
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #differenceType}
* will return {@link DifferenceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #differenceTypeAsString}.
*
*
* @return The type of property difference.
*
* -
*
* ADD
: A value has been added to a resource property that's an array or list data type.
*
*
* -
*
* REMOVE
: The property has been removed from the current resource configuration.
*
*
* -
*
* NOT_EQUAL
: The current property value differs from its expected value (as defined in the
* stack template and any values specified as template parameters).
*
*
* @see DifferenceType
*/
public final DifferenceType differenceType() {
return DifferenceType.fromValue(differenceType);
}
/**
*
* The type of property difference.
*
*
* -
*
* ADD
: A value has been added to a resource property that's an array or list data type.
*
*
* -
*
* REMOVE
: The property has been removed from the current resource configuration.
*
*
* -
*
* NOT_EQUAL
: The current property value differs from its expected value (as defined in the stack
* template and any values specified as template parameters).
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #differenceType}
* will return {@link DifferenceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #differenceTypeAsString}.
*
*
* @return The type of property difference.
*
* -
*
* ADD
: A value has been added to a resource property that's an array or list data type.
*
*
* -
*
* REMOVE
: The property has been removed from the current resource configuration.
*
*
* -
*
* NOT_EQUAL
: The current property value differs from its expected value (as defined in the
* stack template and any values specified as template parameters).
*
*
* @see DifferenceType
*/
public final String differenceTypeAsString() {
return differenceType;
}
@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(propertyPath());
hashCode = 31 * hashCode + Objects.hashCode(expectedValue());
hashCode = 31 * hashCode + Objects.hashCode(actualValue());
hashCode = 31 * hashCode + Objects.hashCode(differenceTypeAsString());
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 PropertyDifference)) {
return false;
}
PropertyDifference other = (PropertyDifference) obj;
return Objects.equals(propertyPath(), other.propertyPath()) && Objects.equals(expectedValue(), other.expectedValue())
&& Objects.equals(actualValue(), other.actualValue())
&& Objects.equals(differenceTypeAsString(), other.differenceTypeAsString());
}
/**
* 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("PropertyDifference").add("PropertyPath", propertyPath()).add("ExpectedValue", expectedValue())
.add("ActualValue", actualValue()).add("DifferenceType", differenceTypeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "PropertyPath":
return Optional.ofNullable(clazz.cast(propertyPath()));
case "ExpectedValue":
return Optional.ofNullable(clazz.cast(expectedValue()));
case "ActualValue":
return Optional.ofNullable(clazz.cast(actualValue()));
case "DifferenceType":
return Optional.ofNullable(clazz.cast(differenceTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function