Record Class Currency

java.lang.Object
java.lang.Record
fr.mathildeuh.youneedme.api.economy.Currency

public record Currency(String id, String symbol, String singularName, String pluralName, int decimalPlaces) extends Record
A currency YouNeedMe's economy can hold a balance in. Servers running a single currency (the default) never need to think about this type at all - every EconomyService method has an overload that assumes id() "default".
  • Constructor Summary

    Constructors
    Constructor
    Description
    Currency(String id, String symbol, String singularName, String pluralName, int decimalPlaces)
    Creates an instance of a Currency record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the decimalPlaces record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    format(double amount)
     
    formatNumber(double amount)
    Just the grouped, fixed-precision number (no symbol/name) - for templates that place the currency symbol/name separately.
    final int
    Returns a hash code value for this object.
    id()
    Returns the value of the id record component.
    Returns the value of the pluralName record component.
    Returns the value of the singularName record component.
    Returns the value of the symbol record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Currency

      public Currency(String id, String symbol, String singularName, String pluralName, int decimalPlaces)
      Creates an instance of a Currency record class.
      Parameters:
      id - the value for the id record component
      symbol - the value for the symbol record component
      singularName - the value for the singularName record component
      pluralName - the value for the pluralName record component
      decimalPlaces - the value for the decimalPlaces record component
  • Method Details

    • format

      public String format(double amount)
    • formatNumber

      public String formatNumber(double amount)
      Just the grouped, fixed-precision number (no symbol/name) - for templates that place the currency symbol/name separately. Built with DecimalFormat rather than a printf-style pattern assembled from decimalPlaces at runtime, since a pattern string built that way can't be statically verified as well-formed.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • symbol

      public String symbol()
      Returns the value of the symbol record component.
      Returns:
      the value of the symbol record component
    • singularName

      public String singularName()
      Returns the value of the singularName record component.
      Returns:
      the value of the singularName record component
    • pluralName

      public String pluralName()
      Returns the value of the pluralName record component.
      Returns:
      the value of the pluralName record component
    • decimalPlaces

      public int decimalPlaces()
      Returns the value of the decimalPlaces record component.
      Returns:
      the value of the decimalPlaces record component