software.amazon.awssdk.services.costexplorer.model.CoverageHours Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of costexplorer Show documentation
Show all versions of costexplorer Show documentation
The AWS Java SDK for AWS Cost Explorer module holds the client classes that are used for communicating
with AWS Cost Explorer Service
/*
* 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;
/**
*
* How long a running instance either used a reservation or was On-Demand.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CoverageHours implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ON_DEMAND_HOURS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("OnDemandHours").getter(getter(CoverageHours::onDemandHours)).setter(setter(Builder::onDemandHours))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OnDemandHours").build()).build();
private static final SdkField RESERVED_HOURS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReservedHours").getter(getter(CoverageHours::reservedHours)).setter(setter(Builder::reservedHours))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReservedHours").build()).build();
private static final SdkField TOTAL_RUNNING_HOURS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TotalRunningHours").getter(getter(CoverageHours::totalRunningHours))
.setter(setter(Builder::totalRunningHours))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TotalRunningHours").build()).build();
private static final SdkField COVERAGE_HOURS_PERCENTAGE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CoverageHoursPercentage").getter(getter(CoverageHours::coverageHoursPercentage))
.setter(setter(Builder::coverageHoursPercentage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CoverageHoursPercentage").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ON_DEMAND_HOURS_FIELD,
RESERVED_HOURS_FIELD, TOTAL_RUNNING_HOURS_FIELD, COVERAGE_HOURS_PERCENTAGE_FIELD));
private static final long serialVersionUID = 1L;
private final String onDemandHours;
private final String reservedHours;
private final String totalRunningHours;
private final String coverageHoursPercentage;
private CoverageHours(BuilderImpl builder) {
this.onDemandHours = builder.onDemandHours;
this.reservedHours = builder.reservedHours;
this.totalRunningHours = builder.totalRunningHours;
this.coverageHoursPercentage = builder.coverageHoursPercentage;
}
/**
*
* The number of instance running hours that On-Demand Instances covered.
*
*
* @return The number of instance running hours that On-Demand Instances covered.
*/
public final String onDemandHours() {
return onDemandHours;
}
/**
*
* The number of instance running hours that reservations covered.
*
*
* @return The number of instance running hours that reservations covered.
*/
public final String reservedHours() {
return reservedHours;
}
/**
*
* The total instance usage, in hours.
*
*
* @return The total instance usage, in hours.
*/
public final String totalRunningHours() {
return totalRunningHours;
}
/**
*
* The percentage of instance hours that a reservation covered.
*
*
* @return The percentage of instance hours that a reservation covered.
*/
public final String coverageHoursPercentage() {
return coverageHoursPercentage;
}
@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(onDemandHours());
hashCode = 31 * hashCode + Objects.hashCode(reservedHours());
hashCode = 31 * hashCode + Objects.hashCode(totalRunningHours());
hashCode = 31 * hashCode + Objects.hashCode(coverageHoursPercentage());
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 CoverageHours)) {
return false;
}
CoverageHours other = (CoverageHours) obj;
return Objects.equals(onDemandHours(), other.onDemandHours()) && Objects.equals(reservedHours(), other.reservedHours())
&& Objects.equals(totalRunningHours(), other.totalRunningHours())
&& Objects.equals(coverageHoursPercentage(), other.coverageHoursPercentage());
}
/**
* 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("CoverageHours").add("OnDemandHours", onDemandHours()).add("ReservedHours", reservedHours())
.add("TotalRunningHours", totalRunningHours()).add("CoverageHoursPercentage", coverageHoursPercentage()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "OnDemandHours":
return Optional.ofNullable(clazz.cast(onDemandHours()));
case "ReservedHours":
return Optional.ofNullable(clazz.cast(reservedHours()));
case "TotalRunningHours":
return Optional.ofNullable(clazz.cast(totalRunningHours()));
case "CoverageHoursPercentage":
return Optional.ofNullable(clazz.cast(coverageHoursPercentage()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function