com.amazonaws.services.ec2.model.Purchase Maven / Gradle / Ivy
Show all versions of aws-java-sdk-ec2 Show documentation
/*
* Copyright 2018-2023 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 com.amazonaws.services.ec2.model;
import java.io.Serializable;
import javax.annotation.Generated;
/**
*
* Describes the result of the purchase.
*
*
* @see AWS API Documentation
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class Purchase implements Serializable, Cloneable {
/**
*
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At this
* time, the only supported currency is USD
.
*
*/
private String currencyCode;
/**
*
* The duration of the reservation's term in seconds.
*
*/
private Integer duration;
/**
*
* The IDs of the Dedicated Hosts associated with the reservation.
*
*/
private com.amazonaws.internal.SdkInternalList hostIdSet;
/**
*
* The ID of the reservation.
*
*/
private String hostReservationId;
/**
*
* The hourly price of the reservation per hour.
*
*/
private String hourlyPrice;
/**
*
* The instance family on the Dedicated Host that the reservation can be associated with.
*
*/
private String instanceFamily;
/**
*
* The payment option for the reservation.
*
*/
private String paymentOption;
/**
*
* The upfront price of the reservation.
*
*/
private String upfrontPrice;
/**
*
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At this
* time, the only supported currency is USD
.
*
*
* @param currencyCode
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At
* this time, the only supported currency is USD
.
* @see CurrencyCodeValues
*/
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
/**
*
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At this
* time, the only supported currency is USD
.
*
*
* @return The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified.
* At this time, the only supported currency is USD
.
* @see CurrencyCodeValues
*/
public String getCurrencyCode() {
return this.currencyCode;
}
/**
*
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At this
* time, the only supported currency is USD
.
*
*
* @param currencyCode
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At
* this time, the only supported currency is USD
.
* @return Returns a reference to this object so that method calls can be chained together.
* @see CurrencyCodeValues
*/
public Purchase withCurrencyCode(String currencyCode) {
setCurrencyCode(currencyCode);
return this;
}
/**
*
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At this
* time, the only supported currency is USD
.
*
*
* @param currencyCode
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At
* this time, the only supported currency is USD
.
* @see CurrencyCodeValues
*/
public void setCurrencyCode(CurrencyCodeValues currencyCode) {
withCurrencyCode(currencyCode);
}
/**
*
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At this
* time, the only supported currency is USD
.
*
*
* @param currencyCode
* The currency in which the UpfrontPrice
and HourlyPrice
amounts are specified. At
* this time, the only supported currency is USD
.
* @return Returns a reference to this object so that method calls can be chained together.
* @see CurrencyCodeValues
*/
public Purchase withCurrencyCode(CurrencyCodeValues currencyCode) {
this.currencyCode = currencyCode.toString();
return this;
}
/**
*
* The duration of the reservation's term in seconds.
*
*
* @param duration
* The duration of the reservation's term in seconds.
*/
public void setDuration(Integer duration) {
this.duration = duration;
}
/**
*
* The duration of the reservation's term in seconds.
*
*
* @return The duration of the reservation's term in seconds.
*/
public Integer getDuration() {
return this.duration;
}
/**
*
* The duration of the reservation's term in seconds.
*
*
* @param duration
* The duration of the reservation's term in seconds.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Purchase withDuration(Integer duration) {
setDuration(duration);
return this;
}
/**
*
* The IDs of the Dedicated Hosts associated with the reservation.
*
*
* @return The IDs of the Dedicated Hosts associated with the reservation.
*/
public java.util.List getHostIdSet() {
if (hostIdSet == null) {
hostIdSet = new com.amazonaws.internal.SdkInternalList();
}
return hostIdSet;
}
/**
*
* The IDs of the Dedicated Hosts associated with the reservation.
*
*
* @param hostIdSet
* The IDs of the Dedicated Hosts associated with the reservation.
*/
public void setHostIdSet(java.util.Collection hostIdSet) {
if (hostIdSet == null) {
this.hostIdSet = null;
return;
}
this.hostIdSet = new com.amazonaws.internal.SdkInternalList(hostIdSet);
}
/**
*
* The IDs of the Dedicated Hosts associated with the reservation.
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setHostIdSet(java.util.Collection)} or {@link #withHostIdSet(java.util.Collection)} if you want to
* override the existing values.
*
*
* @param hostIdSet
* The IDs of the Dedicated Hosts associated with the reservation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Purchase withHostIdSet(String... hostIdSet) {
if (this.hostIdSet == null) {
setHostIdSet(new com.amazonaws.internal.SdkInternalList(hostIdSet.length));
}
for (String ele : hostIdSet) {
this.hostIdSet.add(ele);
}
return this;
}
/**
*
* The IDs of the Dedicated Hosts associated with the reservation.
*
*
* @param hostIdSet
* The IDs of the Dedicated Hosts associated with the reservation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Purchase withHostIdSet(java.util.Collection hostIdSet) {
setHostIdSet(hostIdSet);
return this;
}
/**
*
* The ID of the reservation.
*
*
* @param hostReservationId
* The ID of the reservation.
*/
public void setHostReservationId(String hostReservationId) {
this.hostReservationId = hostReservationId;
}
/**
*
* The ID of the reservation.
*
*
* @return The ID of the reservation.
*/
public String getHostReservationId() {
return this.hostReservationId;
}
/**
*
* The ID of the reservation.
*
*
* @param hostReservationId
* The ID of the reservation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Purchase withHostReservationId(String hostReservationId) {
setHostReservationId(hostReservationId);
return this;
}
/**
*
* The hourly price of the reservation per hour.
*
*
* @param hourlyPrice
* The hourly price of the reservation per hour.
*/
public void setHourlyPrice(String hourlyPrice) {
this.hourlyPrice = hourlyPrice;
}
/**
*
* The hourly price of the reservation per hour.
*
*
* @return The hourly price of the reservation per hour.
*/
public String getHourlyPrice() {
return this.hourlyPrice;
}
/**
*
* The hourly price of the reservation per hour.
*
*
* @param hourlyPrice
* The hourly price of the reservation per hour.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Purchase withHourlyPrice(String hourlyPrice) {
setHourlyPrice(hourlyPrice);
return this;
}
/**
*
* The instance family on the Dedicated Host that the reservation can be associated with.
*
*
* @param instanceFamily
* The instance family on the Dedicated Host that the reservation can be associated with.
*/
public void setInstanceFamily(String instanceFamily) {
this.instanceFamily = instanceFamily;
}
/**
*
* The instance family on the Dedicated Host that the reservation can be associated with.
*
*
* @return The instance family on the Dedicated Host that the reservation can be associated with.
*/
public String getInstanceFamily() {
return this.instanceFamily;
}
/**
*
* The instance family on the Dedicated Host that the reservation can be associated with.
*
*
* @param instanceFamily
* The instance family on the Dedicated Host that the reservation can be associated with.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Purchase withInstanceFamily(String instanceFamily) {
setInstanceFamily(instanceFamily);
return this;
}
/**
*
* The payment option for the reservation.
*
*
* @param paymentOption
* The payment option for the reservation.
* @see PaymentOption
*/
public void setPaymentOption(String paymentOption) {
this.paymentOption = paymentOption;
}
/**
*
* The payment option for the reservation.
*
*
* @return The payment option for the reservation.
* @see PaymentOption
*/
public String getPaymentOption() {
return this.paymentOption;
}
/**
*
* The payment option for the reservation.
*
*
* @param paymentOption
* The payment option for the reservation.
* @return Returns a reference to this object so that method calls can be chained together.
* @see PaymentOption
*/
public Purchase withPaymentOption(String paymentOption) {
setPaymentOption(paymentOption);
return this;
}
/**
*
* The payment option for the reservation.
*
*
* @param paymentOption
* The payment option for the reservation.
* @see PaymentOption
*/
public void setPaymentOption(PaymentOption paymentOption) {
withPaymentOption(paymentOption);
}
/**
*
* The payment option for the reservation.
*
*
* @param paymentOption
* The payment option for the reservation.
* @return Returns a reference to this object so that method calls can be chained together.
* @see PaymentOption
*/
public Purchase withPaymentOption(PaymentOption paymentOption) {
this.paymentOption = paymentOption.toString();
return this;
}
/**
*
* The upfront price of the reservation.
*
*
* @param upfrontPrice
* The upfront price of the reservation.
*/
public void setUpfrontPrice(String upfrontPrice) {
this.upfrontPrice = upfrontPrice;
}
/**
*
* The upfront price of the reservation.
*
*
* @return The upfront price of the reservation.
*/
public String getUpfrontPrice() {
return this.upfrontPrice;
}
/**
*
* The upfront price of the reservation.
*
*
* @param upfrontPrice
* The upfront price of the reservation.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Purchase withUpfrontPrice(String upfrontPrice) {
setUpfrontPrice(upfrontPrice);
return this;
}
/**
* 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.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getCurrencyCode() != null)
sb.append("CurrencyCode: ").append(getCurrencyCode()).append(",");
if (getDuration() != null)
sb.append("Duration: ").append(getDuration()).append(",");
if (getHostIdSet() != null)
sb.append("HostIdSet: ").append(getHostIdSet()).append(",");
if (getHostReservationId() != null)
sb.append("HostReservationId: ").append(getHostReservationId()).append(",");
if (getHourlyPrice() != null)
sb.append("HourlyPrice: ").append(getHourlyPrice()).append(",");
if (getInstanceFamily() != null)
sb.append("InstanceFamily: ").append(getInstanceFamily()).append(",");
if (getPaymentOption() != null)
sb.append("PaymentOption: ").append(getPaymentOption()).append(",");
if (getUpfrontPrice() != null)
sb.append("UpfrontPrice: ").append(getUpfrontPrice());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof Purchase == false)
return false;
Purchase other = (Purchase) obj;
if (other.getCurrencyCode() == null ^ this.getCurrencyCode() == null)
return false;
if (other.getCurrencyCode() != null && other.getCurrencyCode().equals(this.getCurrencyCode()) == false)
return false;
if (other.getDuration() == null ^ this.getDuration() == null)
return false;
if (other.getDuration() != null && other.getDuration().equals(this.getDuration()) == false)
return false;
if (other.getHostIdSet() == null ^ this.getHostIdSet() == null)
return false;
if (other.getHostIdSet() != null && other.getHostIdSet().equals(this.getHostIdSet()) == false)
return false;
if (other.getHostReservationId() == null ^ this.getHostReservationId() == null)
return false;
if (other.getHostReservationId() != null && other.getHostReservationId().equals(this.getHostReservationId()) == false)
return false;
if (other.getHourlyPrice() == null ^ this.getHourlyPrice() == null)
return false;
if (other.getHourlyPrice() != null && other.getHourlyPrice().equals(this.getHourlyPrice()) == false)
return false;
if (other.getInstanceFamily() == null ^ this.getInstanceFamily() == null)
return false;
if (other.getInstanceFamily() != null && other.getInstanceFamily().equals(this.getInstanceFamily()) == false)
return false;
if (other.getPaymentOption() == null ^ this.getPaymentOption() == null)
return false;
if (other.getPaymentOption() != null && other.getPaymentOption().equals(this.getPaymentOption()) == false)
return false;
if (other.getUpfrontPrice() == null ^ this.getUpfrontPrice() == null)
return false;
if (other.getUpfrontPrice() != null && other.getUpfrontPrice().equals(this.getUpfrontPrice()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getCurrencyCode() == null) ? 0 : getCurrencyCode().hashCode());
hashCode = prime * hashCode + ((getDuration() == null) ? 0 : getDuration().hashCode());
hashCode = prime * hashCode + ((getHostIdSet() == null) ? 0 : getHostIdSet().hashCode());
hashCode = prime * hashCode + ((getHostReservationId() == null) ? 0 : getHostReservationId().hashCode());
hashCode = prime * hashCode + ((getHourlyPrice() == null) ? 0 : getHourlyPrice().hashCode());
hashCode = prime * hashCode + ((getInstanceFamily() == null) ? 0 : getInstanceFamily().hashCode());
hashCode = prime * hashCode + ((getPaymentOption() == null) ? 0 : getPaymentOption().hashCode());
hashCode = prime * hashCode + ((getUpfrontPrice() == null) ? 0 : getUpfrontPrice().hashCode());
return hashCode;
}
@Override
public Purchase clone() {
try {
return (Purchase) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
}