software.amazon.awssdk.services.computeoptimizer.model.LicenseRecommendationOption 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.computeoptimizer.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.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.Mutable;
import software.amazon.awssdk.annotations.NotThreadSafe;
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;
/**
*
* Describes the recommendation options for licenses.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class LicenseRecommendationOption implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField RANK_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("rank")
.getter(getter(LicenseRecommendationOption::rank)).setter(setter(Builder::rank))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("rank").build()).build();
private static final SdkField OPERATING_SYSTEM_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("operatingSystem").getter(getter(LicenseRecommendationOption::operatingSystem))
.setter(setter(Builder::operatingSystem))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("operatingSystem").build()).build();
private static final SdkField LICENSE_EDITION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("licenseEdition").getter(getter(LicenseRecommendationOption::licenseEditionAsString))
.setter(setter(Builder::licenseEdition))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("licenseEdition").build()).build();
private static final SdkField LICENSE_MODEL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("licenseModel").getter(getter(LicenseRecommendationOption::licenseModelAsString))
.setter(setter(Builder::licenseModel))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("licenseModel").build()).build();
private static final SdkField SAVINGS_OPPORTUNITY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("savingsOpportunity")
.getter(getter(LicenseRecommendationOption::savingsOpportunity)).setter(setter(Builder::savingsOpportunity))
.constructor(SavingsOpportunity::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("savingsOpportunity").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RANK_FIELD,
OPERATING_SYSTEM_FIELD, LICENSE_EDITION_FIELD, LICENSE_MODEL_FIELD, SAVINGS_OPPORTUNITY_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final Integer rank;
private final String operatingSystem;
private final String licenseEdition;
private final String licenseModel;
private final SavingsOpportunity savingsOpportunity;
private LicenseRecommendationOption(BuilderImpl builder) {
this.rank = builder.rank;
this.operatingSystem = builder.operatingSystem;
this.licenseEdition = builder.licenseEdition;
this.licenseModel = builder.licenseModel;
this.savingsOpportunity = builder.savingsOpportunity;
}
/**
*
* The rank of the license recommendation option.
*
*
* The top recommendation option is ranked as 1.
*
*
* @return The rank of the license recommendation option.
*
* The top recommendation option is ranked as 1.
*/
public final Integer rank() {
return rank;
}
/**
*
* The operating system of a license recommendation option.
*
*
* @return The operating system of a license recommendation option.
*/
public final String operatingSystem() {
return operatingSystem;
}
/**
*
* The recommended edition of the license for the application that runs on the instance.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #licenseEdition}
* will return {@link LicenseEdition#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #licenseEditionAsString}.
*
*
* @return The recommended edition of the license for the application that runs on the instance.
* @see LicenseEdition
*/
public final LicenseEdition licenseEdition() {
return LicenseEdition.fromValue(licenseEdition);
}
/**
*
* The recommended edition of the license for the application that runs on the instance.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #licenseEdition}
* will return {@link LicenseEdition#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #licenseEditionAsString}.
*
*
* @return The recommended edition of the license for the application that runs on the instance.
* @see LicenseEdition
*/
public final String licenseEditionAsString() {
return licenseEdition;
}
/**
*
* The recommended license type associated with the instance.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #licenseModel} will
* return {@link LicenseModel#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #licenseModelAsString}.
*
*
* @return The recommended license type associated with the instance.
* @see LicenseModel
*/
public final LicenseModel licenseModel() {
return LicenseModel.fromValue(licenseModel);
}
/**
*
* The recommended license type associated with the instance.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #licenseModel} will
* return {@link LicenseModel#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #licenseModelAsString}.
*
*
* @return The recommended license type associated with the instance.
* @see LicenseModel
*/
public final String licenseModelAsString() {
return licenseModel;
}
/**
* 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;
}
@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(rank());
hashCode = 31 * hashCode + Objects.hashCode(operatingSystem());
hashCode = 31 * hashCode + Objects.hashCode(licenseEditionAsString());
hashCode = 31 * hashCode + Objects.hashCode(licenseModelAsString());
hashCode = 31 * hashCode + Objects.hashCode(savingsOpportunity());
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 LicenseRecommendationOption)) {
return false;
}
LicenseRecommendationOption other = (LicenseRecommendationOption) obj;
return Objects.equals(rank(), other.rank()) && Objects.equals(operatingSystem(), other.operatingSystem())
&& Objects.equals(licenseEditionAsString(), other.licenseEditionAsString())
&& Objects.equals(licenseModelAsString(), other.licenseModelAsString())
&& Objects.equals(savingsOpportunity(), other.savingsOpportunity());
}
/**
* 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("LicenseRecommendationOption").add("Rank", rank()).add("OperatingSystem", operatingSystem())
.add("LicenseEdition", licenseEditionAsString()).add("LicenseModel", licenseModelAsString())
.add("SavingsOpportunity", savingsOpportunity()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "rank":
return Optional.ofNullable(clazz.cast(rank()));
case "operatingSystem":
return Optional.ofNullable(clazz.cast(operatingSystem()));
case "licenseEdition":
return Optional.ofNullable(clazz.cast(licenseEditionAsString()));
case "licenseModel":
return Optional.ofNullable(clazz.cast(licenseModelAsString()));
case "savingsOpportunity":
return Optional.ofNullable(clazz.cast(savingsOpportunity()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("rank", RANK_FIELD);
map.put("operatingSystem", OPERATING_SYSTEM_FIELD);
map.put("licenseEdition", LICENSE_EDITION_FIELD);
map.put("licenseModel", LICENSE_MODEL_FIELD);
map.put("savingsOpportunity", SAVINGS_OPPORTUNITY_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function