software.amazon.awssdk.services.computeoptimizer.model.LicenseConfiguration 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 configuration of a license for an Amazon EC2 instance.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class LicenseConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField NUMBER_OF_CORES_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("numberOfCores").getter(getter(LicenseConfiguration::numberOfCores))
.setter(setter(Builder::numberOfCores))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("numberOfCores").build()).build();
private static final SdkField INSTANCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("instanceType").getter(getter(LicenseConfiguration::instanceType)).setter(setter(Builder::instanceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("instanceType").build()).build();
private static final SdkField OPERATING_SYSTEM_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("operatingSystem").getter(getter(LicenseConfiguration::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(LicenseConfiguration::licenseEditionAsString))
.setter(setter(Builder::licenseEdition))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("licenseEdition").build()).build();
private static final SdkField LICENSE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("licenseName").getter(getter(LicenseConfiguration::licenseNameAsString))
.setter(setter(Builder::licenseName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("licenseName").build()).build();
private static final SdkField LICENSE_MODEL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("licenseModel").getter(getter(LicenseConfiguration::licenseModelAsString))
.setter(setter(Builder::licenseModel))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("licenseModel").build()).build();
private static final SdkField LICENSE_VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("licenseVersion").getter(getter(LicenseConfiguration::licenseVersion))
.setter(setter(Builder::licenseVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("licenseVersion").build()).build();
private static final SdkField> METRICS_SOURCE_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("metricsSource")
.getter(getter(LicenseConfiguration::metricsSource))
.setter(setter(Builder::metricsSource))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("metricsSource").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(MetricSource::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NUMBER_OF_CORES_FIELD,
INSTANCE_TYPE_FIELD, OPERATING_SYSTEM_FIELD, LICENSE_EDITION_FIELD, LICENSE_NAME_FIELD, LICENSE_MODEL_FIELD,
LICENSE_VERSION_FIELD, METRICS_SOURCE_FIELD));
private static final long serialVersionUID = 1L;
private final Integer numberOfCores;
private final String instanceType;
private final String operatingSystem;
private final String licenseEdition;
private final String licenseName;
private final String licenseModel;
private final String licenseVersion;
private final List metricsSource;
private LicenseConfiguration(BuilderImpl builder) {
this.numberOfCores = builder.numberOfCores;
this.instanceType = builder.instanceType;
this.operatingSystem = builder.operatingSystem;
this.licenseEdition = builder.licenseEdition;
this.licenseName = builder.licenseName;
this.licenseModel = builder.licenseModel;
this.licenseVersion = builder.licenseVersion;
this.metricsSource = builder.metricsSource;
}
/**
*
* The current number of cores associated with the instance.
*
*
* @return The current number of cores associated with the instance.
*/
public final Integer numberOfCores() {
return numberOfCores;
}
/**
*
* The instance type used in the license.
*
*
* @return The instance type used in the license.
*/
public final String instanceType() {
return instanceType;
}
/**
*
* The operating system of the instance.
*
*
* @return The operating system of the instance.
*/
public final String operatingSystem() {
return operatingSystem;
}
/**
*
* The 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 edition of the license for the application that runs on the instance.
* @see LicenseEdition
*/
public final LicenseEdition licenseEdition() {
return LicenseEdition.fromValue(licenseEdition);
}
/**
*
* The 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 edition of the license for the application that runs on the instance.
* @see LicenseEdition
*/
public final String licenseEditionAsString() {
return licenseEdition;
}
/**
*
* The name 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 #licenseName} will
* return {@link LicenseName#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #licenseNameAsString}.
*
*
* @return The name of the license for the application that runs on the instance.
* @see LicenseName
*/
public final LicenseName licenseName() {
return LicenseName.fromValue(licenseName);
}
/**
*
* The name 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 #licenseName} will
* return {@link LicenseName#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #licenseNameAsString}.
*
*
* @return The name of the license for the application that runs on the instance.
* @see LicenseName
*/
public final String licenseNameAsString() {
return licenseName;
}
/**
*
* The 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 license type associated with the instance.
* @see LicenseModel
*/
public final LicenseModel licenseModel() {
return LicenseModel.fromValue(licenseModel);
}
/**
*
* The 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 license type associated with the instance.
* @see LicenseModel
*/
public final String licenseModelAsString() {
return licenseModel;
}
/**
*
* The version of the license for the application that runs on the instance.
*
*
* @return The version of the license for the application that runs on the instance.
*/
public final String licenseVersion() {
return licenseVersion;
}
/**
* For responses, this returns true if the service returned a value for the MetricsSource 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 hasMetricsSource() {
return metricsSource != null && !(metricsSource instanceof SdkAutoConstructList);
}
/**
*
* The list of metric sources required to generate recommendations for commercial software licenses.
*
*
* 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 #hasMetricsSource} method.
*
*
* @return The list of metric sources required to generate recommendations for commercial software licenses.
*/
public final List metricsSource() {
return metricsSource;
}
@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(numberOfCores());
hashCode = 31 * hashCode + Objects.hashCode(instanceType());
hashCode = 31 * hashCode + Objects.hashCode(operatingSystem());
hashCode = 31 * hashCode + Objects.hashCode(licenseEditionAsString());
hashCode = 31 * hashCode + Objects.hashCode(licenseNameAsString());
hashCode = 31 * hashCode + Objects.hashCode(licenseModelAsString());
hashCode = 31 * hashCode + Objects.hashCode(licenseVersion());
hashCode = 31 * hashCode + Objects.hashCode(hasMetricsSource() ? metricsSource() : null);
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 LicenseConfiguration)) {
return false;
}
LicenseConfiguration other = (LicenseConfiguration) obj;
return Objects.equals(numberOfCores(), other.numberOfCores()) && Objects.equals(instanceType(), other.instanceType())
&& Objects.equals(operatingSystem(), other.operatingSystem())
&& Objects.equals(licenseEditionAsString(), other.licenseEditionAsString())
&& Objects.equals(licenseNameAsString(), other.licenseNameAsString())
&& Objects.equals(licenseModelAsString(), other.licenseModelAsString())
&& Objects.equals(licenseVersion(), other.licenseVersion()) && hasMetricsSource() == other.hasMetricsSource()
&& Objects.equals(metricsSource(), other.metricsSource());
}
/**
* 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("LicenseConfiguration").add("NumberOfCores", numberOfCores()).add("InstanceType", instanceType())
.add("OperatingSystem", operatingSystem()).add("LicenseEdition", licenseEditionAsString())
.add("LicenseName", licenseNameAsString()).add("LicenseModel", licenseModelAsString())
.add("LicenseVersion", licenseVersion()).add("MetricsSource", hasMetricsSource() ? metricsSource() : null)
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "numberOfCores":
return Optional.ofNullable(clazz.cast(numberOfCores()));
case "instanceType":
return Optional.ofNullable(clazz.cast(instanceType()));
case "operatingSystem":
return Optional.ofNullable(clazz.cast(operatingSystem()));
case "licenseEdition":
return Optional.ofNullable(clazz.cast(licenseEditionAsString()));
case "licenseName":
return Optional.ofNullable(clazz.cast(licenseNameAsString()));
case "licenseModel":
return Optional.ofNullable(clazz.cast(licenseModelAsString()));
case "licenseVersion":
return Optional.ofNullable(clazz.cast(licenseVersion()));
case "metricsSource":
return Optional.ofNullable(clazz.cast(metricsSource()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function