software.amazon.awssdk.services.computeoptimizer.model.RDSDBInstanceRecommendationOption Maven / Gradle / Ivy
Show all versions of computeoptimizer 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.computeoptimizer.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;
/**
*
* Describes the recommendation options for an Amazon RDS instance.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class RDSDBInstanceRecommendationOption implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField DB_INSTANCE_CLASS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("dbInstanceClass").getter(getter(RDSDBInstanceRecommendationOption::dbInstanceClass))
.setter(setter(Builder::dbInstanceClass))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("dbInstanceClass").build()).build();
private static final SdkField> PROJECTED_UTILIZATION_METRICS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("projectedUtilizationMetrics")
.getter(getter(RDSDBInstanceRecommendationOption::projectedUtilizationMetrics))
.setter(setter(Builder::projectedUtilizationMetrics))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("projectedUtilizationMetrics")
.build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(RDSDBUtilizationMetric::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField PERFORMANCE_RISK_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("performanceRisk").getter(getter(RDSDBInstanceRecommendationOption::performanceRisk))
.setter(setter(Builder::performanceRisk))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("performanceRisk").build()).build();
private static final SdkField RANK_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("rank")
.getter(getter(RDSDBInstanceRecommendationOption::rank)).setter(setter(Builder::rank))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("rank").build()).build();
private static final SdkField SAVINGS_OPPORTUNITY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("savingsOpportunity")
.getter(getter(RDSDBInstanceRecommendationOption::savingsOpportunity)).setter(setter(Builder::savingsOpportunity))
.constructor(SavingsOpportunity::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("savingsOpportunity").build())
.build();
private static final SdkField SAVINGS_OPPORTUNITY_AFTER_DISCOUNTS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("savingsOpportunityAfterDiscounts")
.getter(getter(RDSDBInstanceRecommendationOption::savingsOpportunityAfterDiscounts))
.setter(setter(Builder::savingsOpportunityAfterDiscounts))
.constructor(RDSInstanceSavingsOpportunityAfterDiscounts::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("savingsOpportunityAfterDiscounts")
.build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DB_INSTANCE_CLASS_FIELD,
PROJECTED_UTILIZATION_METRICS_FIELD, PERFORMANCE_RISK_FIELD, RANK_FIELD, SAVINGS_OPPORTUNITY_FIELD,
SAVINGS_OPPORTUNITY_AFTER_DISCOUNTS_FIELD));
private static final long serialVersionUID = 1L;
private final String dbInstanceClass;
private final List projectedUtilizationMetrics;
private final Double performanceRisk;
private final Integer rank;
private final SavingsOpportunity savingsOpportunity;
private final RDSInstanceSavingsOpportunityAfterDiscounts savingsOpportunityAfterDiscounts;
private RDSDBInstanceRecommendationOption(BuilderImpl builder) {
this.dbInstanceClass = builder.dbInstanceClass;
this.projectedUtilizationMetrics = builder.projectedUtilizationMetrics;
this.performanceRisk = builder.performanceRisk;
this.rank = builder.rank;
this.savingsOpportunity = builder.savingsOpportunity;
this.savingsOpportunityAfterDiscounts = builder.savingsOpportunityAfterDiscounts;
}
/**
*
* Describes the DB instance class recommendation option for your Amazon RDS instance.
*
*
* @return Describes the DB instance class recommendation option for your Amazon RDS instance.
*/
public final String dbInstanceClass() {
return dbInstanceClass;
}
/**
* For responses, this returns true if the service returned a value for the ProjectedUtilizationMetrics 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 hasProjectedUtilizationMetrics() {
return projectedUtilizationMetrics != null && !(projectedUtilizationMetrics instanceof SdkAutoConstructList);
}
/**
*
* An array of objects that describe the projected utilization metrics of the RDS instance recommendation option.
*
*
* 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 #hasProjectedUtilizationMetrics} method.
*
*
* @return An array of objects that describe the projected utilization metrics of the RDS instance recommendation
* option.
*/
public final List projectedUtilizationMetrics() {
return projectedUtilizationMetrics;
}
/**
*
* The performance risk of the RDS instance recommendation option.
*
*
* @return The performance risk of the RDS instance recommendation option.
*/
public final Double performanceRisk() {
return performanceRisk;
}
/**
*
* The rank identifier of the RDS instance recommendation option.
*
*
* @return The rank identifier of the RDS instance recommendation option.
*/
public final Integer rank() {
return rank;
}
/**
* Returns the value of the SavingsOpportunity property for this object.
*
* @return The value of the SavingsOpportunity property for this object.
*/
public final SavingsOpportunity savingsOpportunity() {
return savingsOpportunity;
}
/**
*
* Describes the savings opportunity for Amazon RDS recommendations or for the recommendation option.
*
*
* Savings opportunity represents the estimated monthly savings after applying Savings Plans discounts. You can
* achieve this by implementing a given Compute Optimizer recommendation.
*
*
* @return Describes the savings opportunity for Amazon RDS recommendations or for the recommendation option.
*
* Savings opportunity represents the estimated monthly savings after applying Savings Plans discounts. You
* can achieve this by implementing a given Compute Optimizer recommendation.
*/
public final RDSInstanceSavingsOpportunityAfterDiscounts savingsOpportunityAfterDiscounts() {
return savingsOpportunityAfterDiscounts;
}
@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(dbInstanceClass());
hashCode = 31 * hashCode + Objects.hashCode(hasProjectedUtilizationMetrics() ? projectedUtilizationMetrics() : null);
hashCode = 31 * hashCode + Objects.hashCode(performanceRisk());
hashCode = 31 * hashCode + Objects.hashCode(rank());
hashCode = 31 * hashCode + Objects.hashCode(savingsOpportunity());
hashCode = 31 * hashCode + Objects.hashCode(savingsOpportunityAfterDiscounts());
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 RDSDBInstanceRecommendationOption)) {
return false;
}
RDSDBInstanceRecommendationOption other = (RDSDBInstanceRecommendationOption) obj;
return Objects.equals(dbInstanceClass(), other.dbInstanceClass())
&& hasProjectedUtilizationMetrics() == other.hasProjectedUtilizationMetrics()
&& Objects.equals(projectedUtilizationMetrics(), other.projectedUtilizationMetrics())
&& Objects.equals(performanceRisk(), other.performanceRisk()) && Objects.equals(rank(), other.rank())
&& Objects.equals(savingsOpportunity(), other.savingsOpportunity())
&& Objects.equals(savingsOpportunityAfterDiscounts(), other.savingsOpportunityAfterDiscounts());
}
/**
* 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("RDSDBInstanceRecommendationOption").add("DbInstanceClass", dbInstanceClass())
.add("ProjectedUtilizationMetrics", hasProjectedUtilizationMetrics() ? projectedUtilizationMetrics() : null)
.add("PerformanceRisk", performanceRisk()).add("Rank", rank()).add("SavingsOpportunity", savingsOpportunity())
.add("SavingsOpportunityAfterDiscounts", savingsOpportunityAfterDiscounts()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "dbInstanceClass":
return Optional.ofNullable(clazz.cast(dbInstanceClass()));
case "projectedUtilizationMetrics":
return Optional.ofNullable(clazz.cast(projectedUtilizationMetrics()));
case "performanceRisk":
return Optional.ofNullable(clazz.cast(performanceRisk()));
case "rank":
return Optional.ofNullable(clazz.cast(rank()));
case "savingsOpportunity":
return Optional.ofNullable(clazz.cast(savingsOpportunity()));
case "savingsOpportunityAfterDiscounts":
return Optional.ofNullable(clazz.cast(savingsOpportunityAfterDiscounts()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function