
software.amazon.awssdk.services.memorydb.model.ReservedNode 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.memorydb.model;
import java.io.Serializable;
import java.time.Instant;
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;
/**
*
* Represents the output of a PurchaseReservedNodesOffering
operation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ReservedNode implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField RESERVATION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReservationId").getter(getter(ReservedNode::reservationId)).setter(setter(Builder::reservationId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReservationId").build()).build();
private static final SdkField RESERVED_NODES_OFFERING_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReservedNodesOfferingId").getter(getter(ReservedNode::reservedNodesOfferingId))
.setter(setter(Builder::reservedNodesOfferingId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReservedNodesOfferingId").build())
.build();
private static final SdkField NODE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NodeType").getter(getter(ReservedNode::nodeType)).setter(setter(Builder::nodeType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeType").build()).build();
private static final SdkField START_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("StartTime").getter(getter(ReservedNode::startTime)).setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartTime").build()).build();
private static final SdkField DURATION_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Duration").getter(getter(ReservedNode::duration)).setter(setter(Builder::duration))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Duration").build()).build();
private static final SdkField FIXED_PRICE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("FixedPrice").getter(getter(ReservedNode::fixedPrice)).setter(setter(Builder::fixedPrice))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FixedPrice").build()).build();
private static final SdkField NODE_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("NodeCount").getter(getter(ReservedNode::nodeCount)).setter(setter(Builder::nodeCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeCount").build()).build();
private static final SdkField OFFERING_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("OfferingType").getter(getter(ReservedNode::offeringType)).setter(setter(Builder::offeringType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OfferingType").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(ReservedNode::state)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField> RECURRING_CHARGES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("RecurringCharges")
.getter(getter(ReservedNode::recurringCharges))
.setter(setter(Builder::recurringCharges))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecurringCharges").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(RecurringCharge::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("ARN")
.getter(getter(ReservedNode::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ARN").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RESERVATION_ID_FIELD,
RESERVED_NODES_OFFERING_ID_FIELD, NODE_TYPE_FIELD, START_TIME_FIELD, DURATION_FIELD, FIXED_PRICE_FIELD,
NODE_COUNT_FIELD, OFFERING_TYPE_FIELD, STATE_FIELD, RECURRING_CHARGES_FIELD, ARN_FIELD));
private static final long serialVersionUID = 1L;
private final String reservationId;
private final String reservedNodesOfferingId;
private final String nodeType;
private final Instant startTime;
private final Integer duration;
private final Double fixedPrice;
private final Integer nodeCount;
private final String offeringType;
private final String state;
private final List recurringCharges;
private final String arn;
private ReservedNode(BuilderImpl builder) {
this.reservationId = builder.reservationId;
this.reservedNodesOfferingId = builder.reservedNodesOfferingId;
this.nodeType = builder.nodeType;
this.startTime = builder.startTime;
this.duration = builder.duration;
this.fixedPrice = builder.fixedPrice;
this.nodeCount = builder.nodeCount;
this.offeringType = builder.offeringType;
this.state = builder.state;
this.recurringCharges = builder.recurringCharges;
this.arn = builder.arn;
}
/**
*
* A customer-specified identifier to track this reservation.
*
*
* @return A customer-specified identifier to track this reservation.
*/
public final String reservationId() {
return reservationId;
}
/**
*
* The ID of the reserved node offering to purchase.
*
*
* @return The ID of the reserved node offering to purchase.
*/
public final String reservedNodesOfferingId() {
return reservedNodesOfferingId;
}
/**
*
* The node type for the reserved nodes.
*
*
* @return The node type for the reserved nodes.
*/
public final String nodeType() {
return nodeType;
}
/**
*
* The time the reservation started.
*
*
* @return The time the reservation started.
*/
public final Instant startTime() {
return startTime;
}
/**
*
* The duration of the reservation in seconds.
*
*
* @return The duration of the reservation in seconds.
*/
public final Integer duration() {
return duration;
}
/**
*
* The fixed price charged for this reserved node.
*
*
* @return The fixed price charged for this reserved node.
*/
public final Double fixedPrice() {
return fixedPrice;
}
/**
*
* The number of nodes that have been reserved.
*
*
* @return The number of nodes that have been reserved.
*/
public final Integer nodeCount() {
return nodeCount;
}
/**
*
* The offering type of this reserved node.
*
*
* @return The offering type of this reserved node.
*/
public final String offeringType() {
return offeringType;
}
/**
*
* The state of the reserved node.
*
*
* @return The state of the reserved node.
*/
public final String state() {
return state;
}
/**
* For responses, this returns true if the service returned a value for the RecurringCharges 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 hasRecurringCharges() {
return recurringCharges != null && !(recurringCharges instanceof SdkAutoConstructList);
}
/**
*
* The recurring price charged to run this reserved node.
*
*
* 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 #hasRecurringCharges} method.
*
*
* @return The recurring price charged to run this reserved node.
*/
public final List recurringCharges() {
return recurringCharges;
}
/**
*
* The Amazon Resource Name (ARN) of the reserved node.
*
*
* @return The Amazon Resource Name (ARN) of the reserved node.
*/
public final String arn() {
return arn;
}
@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(reservationId());
hashCode = 31 * hashCode + Objects.hashCode(reservedNodesOfferingId());
hashCode = 31 * hashCode + Objects.hashCode(nodeType());
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(duration());
hashCode = 31 * hashCode + Objects.hashCode(fixedPrice());
hashCode = 31 * hashCode + Objects.hashCode(nodeCount());
hashCode = 31 * hashCode + Objects.hashCode(offeringType());
hashCode = 31 * hashCode + Objects.hashCode(state());
hashCode = 31 * hashCode + Objects.hashCode(hasRecurringCharges() ? recurringCharges() : null);
hashCode = 31 * hashCode + Objects.hashCode(arn());
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 ReservedNode)) {
return false;
}
ReservedNode other = (ReservedNode) obj;
return Objects.equals(reservationId(), other.reservationId())
&& Objects.equals(reservedNodesOfferingId(), other.reservedNodesOfferingId())
&& Objects.equals(nodeType(), other.nodeType()) && Objects.equals(startTime(), other.startTime())
&& Objects.equals(duration(), other.duration()) && Objects.equals(fixedPrice(), other.fixedPrice())
&& Objects.equals(nodeCount(), other.nodeCount()) && Objects.equals(offeringType(), other.offeringType())
&& Objects.equals(state(), other.state()) && hasRecurringCharges() == other.hasRecurringCharges()
&& Objects.equals(recurringCharges(), other.recurringCharges()) && Objects.equals(arn(), other.arn());
}
/**
* 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("ReservedNode").add("ReservationId", reservationId())
.add("ReservedNodesOfferingId", reservedNodesOfferingId()).add("NodeType", nodeType())
.add("StartTime", startTime()).add("Duration", duration()).add("FixedPrice", fixedPrice())
.add("NodeCount", nodeCount()).add("OfferingType", offeringType()).add("State", state())
.add("RecurringCharges", hasRecurringCharges() ? recurringCharges() : null).add("ARN", arn()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ReservationId":
return Optional.ofNullable(clazz.cast(reservationId()));
case "ReservedNodesOfferingId":
return Optional.ofNullable(clazz.cast(reservedNodesOfferingId()));
case "NodeType":
return Optional.ofNullable(clazz.cast(nodeType()));
case "StartTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "Duration":
return Optional.ofNullable(clazz.cast(duration()));
case "FixedPrice":
return Optional.ofNullable(clazz.cast(fixedPrice()));
case "NodeCount":
return Optional.ofNullable(clazz.cast(nodeCount()));
case "OfferingType":
return Optional.ofNullable(clazz.cast(offeringType()));
case "State":
return Optional.ofNullable(clazz.cast(state()));
case "RecurringCharges":
return Optional.ofNullable(clazz.cast(recurringCharges()));
case "ARN":
return Optional.ofNullable(clazz.cast(arn()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function