software.amazon.awssdk.services.costexplorer.model.Impact Maven / Gradle / Ivy
Show all versions of costexplorer 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.costexplorer.model;
import java.io.Serializable;
import java.util.Arrays;
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 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;
/**
*
* The dollar value of the anomaly.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Impact implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField MAX_IMPACT_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("MaxImpact").getter(getter(Impact::maxImpact)).setter(setter(Builder::maxImpact))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxImpact").build()).build();
private static final SdkField TOTAL_IMPACT_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("TotalImpact").getter(getter(Impact::totalImpact)).setter(setter(Builder::totalImpact))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TotalImpact").build()).build();
private static final SdkField TOTAL_ACTUAL_SPEND_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("TotalActualSpend").getter(getter(Impact::totalActualSpend)).setter(setter(Builder::totalActualSpend))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TotalActualSpend").build()).build();
private static final SdkField TOTAL_EXPECTED_SPEND_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("TotalExpectedSpend").getter(getter(Impact::totalExpectedSpend))
.setter(setter(Builder::totalExpectedSpend))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TotalExpectedSpend").build())
.build();
private static final SdkField TOTAL_IMPACT_PERCENTAGE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("TotalImpactPercentage").getter(getter(Impact::totalImpactPercentage))
.setter(setter(Builder::totalImpactPercentage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TotalImpactPercentage").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(MAX_IMPACT_FIELD,
TOTAL_IMPACT_FIELD, TOTAL_ACTUAL_SPEND_FIELD, TOTAL_EXPECTED_SPEND_FIELD, TOTAL_IMPACT_PERCENTAGE_FIELD));
private static final long serialVersionUID = 1L;
private final Double maxImpact;
private final Double totalImpact;
private final Double totalActualSpend;
private final Double totalExpectedSpend;
private final Double totalImpactPercentage;
private Impact(BuilderImpl builder) {
this.maxImpact = builder.maxImpact;
this.totalImpact = builder.totalImpact;
this.totalActualSpend = builder.totalActualSpend;
this.totalExpectedSpend = builder.totalExpectedSpend;
this.totalImpactPercentage = builder.totalImpactPercentage;
}
/**
*
* The maximum dollar value that's observed for an anomaly.
*
*
* @return The maximum dollar value that's observed for an anomaly.
*/
public final Double maxImpact() {
return maxImpact;
}
/**
*
* The cumulative dollar difference between the total actual spend and total expected spend. It is calculated as
* TotalActualSpend - TotalExpectedSpend
.
*
*
* @return The cumulative dollar difference between the total actual spend and total expected spend. It is
* calculated as TotalActualSpend - TotalExpectedSpend
.
*/
public final Double totalImpact() {
return totalImpact;
}
/**
*
* The cumulative dollar amount that was actually spent during the anomaly.
*
*
* @return The cumulative dollar amount that was actually spent during the anomaly.
*/
public final Double totalActualSpend() {
return totalActualSpend;
}
/**
*
* The cumulative dollar amount that was expected to be spent during the anomaly. It is calculated using advanced
* machine learning models to determine the typical spending pattern based on historical data for a customer.
*
*
* @return The cumulative dollar amount that was expected to be spent during the anomaly. It is calculated using
* advanced machine learning models to determine the typical spending pattern based on historical data for a
* customer.
*/
public final Double totalExpectedSpend() {
return totalExpectedSpend;
}
/**
*
* The cumulative percentage difference between the total actual spend and total expected spend. It is calculated as
* (TotalImpact / TotalExpectedSpend) * 100
. When TotalExpectedSpend
is zero, this field
* is omitted. Expected spend can be zero in situations such as when you start to use a service for the first time.
*
*
* @return The cumulative percentage difference between the total actual spend and total expected spend. It is
* calculated as (TotalImpact / TotalExpectedSpend) * 100
. When TotalExpectedSpend
* is zero, this field is omitted. Expected spend can be zero in situations such as when you start to use a
* service for the first time.
*/
public final Double totalImpactPercentage() {
return totalImpactPercentage;
}
@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(maxImpact());
hashCode = 31 * hashCode + Objects.hashCode(totalImpact());
hashCode = 31 * hashCode + Objects.hashCode(totalActualSpend());
hashCode = 31 * hashCode + Objects.hashCode(totalExpectedSpend());
hashCode = 31 * hashCode + Objects.hashCode(totalImpactPercentage());
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 Impact)) {
return false;
}
Impact other = (Impact) obj;
return Objects.equals(maxImpact(), other.maxImpact()) && Objects.equals(totalImpact(), other.totalImpact())
&& Objects.equals(totalActualSpend(), other.totalActualSpend())
&& Objects.equals(totalExpectedSpend(), other.totalExpectedSpend())
&& Objects.equals(totalImpactPercentage(), other.totalImpactPercentage());
}
/**
* 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("Impact").add("MaxImpact", maxImpact()).add("TotalImpact", totalImpact())
.add("TotalActualSpend", totalActualSpend()).add("TotalExpectedSpend", totalExpectedSpend())
.add("TotalImpactPercentage", totalImpactPercentage()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "MaxImpact":
return Optional.ofNullable(clazz.cast(maxImpact()));
case "TotalImpact":
return Optional.ofNullable(clazz.cast(totalImpact()));
case "TotalActualSpend":
return Optional.ofNullable(clazz.cast(totalActualSpend()));
case "TotalExpectedSpend":
return Optional.ofNullable(clazz.cast(totalExpectedSpend()));
case "TotalImpactPercentage":
return Optional.ofNullable(clazz.cast(totalImpactPercentage()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function