Class Payment

  • All Implemented Interfaces:
    FxConvertible<Payment>, java.io.Serializable, Bean, ImmutableBean

    public final class Payment
    extends java.lang.Object
    implements FxConvertible<Payment>, ImmutableBean, java.io.Serializable
    A single payment of a known amount on a specific date.

    This class represents a payment, where the payment date and amount are known. A negative value indicates the amount is to be paid while a positive value indicates the amount is received.

    See Also:
    Serialized Form
    • Method Detail

      • of

        public static Payment of​(Currency currency,
                                 double amount,
                                 java.time.LocalDate date)
        Obtains an instance representing an amount.

        Whether the payment is pay or receive is determined by the sign of the specified amount.

        Parameters:
        currency - the currency of the payment
        amount - the amount of the payment
        date - the date that the payment is made
        Returns:
        the payment instance
      • of

        public static Payment of​(CurrencyAmount value,
                                 java.time.LocalDate date)
        Obtains an instance representing an amount.

        Whether the payment is pay or receive is determined by the sign of the specified amount.

        Parameters:
        value - the amount of the payment
        date - the date that the payment is made
        Returns:
        the payment instance
      • ofPay

        public static Payment ofPay​(CurrencyAmount value,
                                    java.time.LocalDate date)
        Obtains an instance representing an amount to be paid.

        The sign of the amount will be normalized to be negative, indicating a payment.

        Parameters:
        value - the amount of the payment
        date - the date that the payment is made
        Returns:
        the payment instance
      • ofReceive

        public static Payment ofReceive​(CurrencyAmount value,
                                        java.time.LocalDate date)
        Obtains an instance representing an amount to be received.

        The sign of the amount will be normalized to be positive, indicating receipt.

        Parameters:
        value - the amount of the payment
        date - the date that the payment is made
        Returns:
        the payment instance
      • getCurrency

        public Currency getCurrency()
        Gets the currency of the payment.

        This simply returns getValue().getCurrency().

        Returns:
        the currency of the payment
      • getAmount

        public double getAmount()
        Gets the amount of the payment.

        The payment value is signed. A negative value indicates a payment while a positive value indicates receipt.

        This simply returns getValue().getAmount().

        Returns:
        the amount of the payment
      • adjustDate

        public Payment adjustDate​(java.time.temporal.TemporalAdjuster adjuster)
        Adjusts the payment date using the rules of the specified adjuster.

        The adjuster is typically an instance of BusinessDayAdjustment. If the date is unchanged by the adjuster, this payment will be returned.

        Parameters:
        adjuster - the adjuster to apply to the payment date
        Returns:
        the adjusted payment
      • negated

        public Payment negated()
        Returns a copy of this Payment with the value negated.

        This takes this payment and negates it.

        This instance is immutable and unaffected by this method.

        Returns:
        a payment based on this with the value negated
      • convertedTo

        public Payment convertedTo​(Currency resultCurrency,
                                   FxRateProvider rateProvider)
        Converts this payment to an equivalent payment in the specified currency.

        The result will be expressed in terms of the given currency. If conversion is needed, the provider will be used to supply the FX rate.

        Specified by:
        convertedTo in interface FxConvertible<Payment>
        Parameters:
        resultCurrency - the currency of the result
        rateProvider - the provider of FX rates
        Returns:
        the converted instance, in the specified currency
        Throws:
        java.lang.RuntimeException - if no FX rate could be found
      • meta

        public static Payment.Meta meta()
        The meta-bean for Payment.
        Returns:
        the meta-bean, not null
      • builder

        public static Payment.Builder builder()
        Returns a builder used to create an instance of the bean.
        Returns:
        the builder, not null
      • getValue

        public CurrencyAmount getValue()
        Gets the amount of the payment.

        The amount is signed. A negative value indicates the amount is to be paid while a positive value indicates the amount is received.

        Returns:
        the value of the property, not null
      • getDate

        public java.time.LocalDate getDate()
        Gets the date that the payment is made.

        This date should normally be a valid business day.

        Returns:
        the value of the property, not null
      • toBuilder

        public Payment.Builder toBuilder()
        Returns a builder that allows this bean to be mutated.
        Returns:
        the mutable builder, not null
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object