src/main/java/jp/ne/paypay/model/MoneyAmount.java
package jp.ne.paypay.model;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Objects;
import io.swagger.annotations.ApiModelProperty;
/**
* MoneyAmount
*/
public class MoneyAmount {
@SerializedName("amount")
private Integer amount = null;
/**
* Gets or Sets currency
*/
@JsonAdapter(CurrencyEnum.Adapter.class)
public enum CurrencyEnum {
JPY("JPY");
private String value;
CurrencyEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static CurrencyEnum fromValue(String text) {
for (CurrencyEnum b : CurrencyEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
public static class Adapter extends TypeAdapter<CurrencyEnum> {
@Override
public void write(final JsonWriter jsonWriter, final CurrencyEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public CurrencyEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return CurrencyEnum.fromValue(String.valueOf(value));
}
}
}
@SerializedName("currency")
private CurrencyEnum currency = null;
public MoneyAmount amount(Integer amount) {
this.amount = amount;
return this;
}
/**
* Get amount
* @return amount
**/
@ApiModelProperty(required = true, value = "")
public Integer getAmount() {
return amount;
}
public void setAmount(Integer amount) {
this.amount = amount;
}
public MoneyAmount currency(CurrencyEnum currency) {
this.currency = currency;
return this;
}
/**
* Get currency
* @return currency
**/
@ApiModelProperty(required = true, value = "")
public CurrencyEnum getCurrency() {
return currency;
}
public void setCurrency(CurrencyEnum currency) {
this.currency = currency;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MoneyAmount moneyAmount = (MoneyAmount) o;
return Objects.equals(this.amount, moneyAmount.amount) &&
Objects.equals(this.currency, moneyAmount.currency);
}
@Override
public int hashCode() {
return Objects.hash(amount, currency);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class MoneyAmount {\n");
sb.append(" amount: ").append(toIndentedString(amount)).append("\n");
sb.append(" currency: ").append(toIndentedString(currency)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}