All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.twitch4j.common.util.DonationAmount Maven / Gradle / Ivy

There is a newer version: 1.23.0
Show newest version
package com.github.twitch4j.common.util;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Currency;

@Data
@Setter(AccessLevel.PRIVATE)
@NoArgsConstructor
@AllArgsConstructor
public class DonationAmount {

    /**
     * The monetary amount.
     * 

* The amount is specified in the currency’s minor unit. *

* For example, the minor units for USD is cents, so if the amount is $5.50 USD, value is set to 550. */ @JsonAlias({ "amount", "donation_amount" }) private Long value; /** * The number of decimal places used by the currency. *

* For example, USD uses two decimal places. */ @JsonAlias("exponent") private Integer decimalPlaces; /** * The ISO-4217 three-letter currency code that identifies the type of currency in {@link #getValue()}. */ @JsonAlias({ "campaign_currency", "donation_currency" }) private String currency; /** * The {@link Currency} corresponding to the ISO-4217 code contained in {@link #getCurrency()}. */ @JsonIgnore @Getter(lazy = true) @EqualsAndHashCode.Exclude private final Currency parsedCurrency = Currency.getInstance(getCurrency()); /** * The donation amount, with the appropriate decimals, based on {@link #getValue()}. */ @JsonIgnore @Getter(lazy = true) @EqualsAndHashCode.Exclude private final BigDecimal parsedValue = BigDecimal.valueOf(getValue(), getDecimalPlaces()); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy