Class CheckerCurrency

java.lang.Object
com.luchersol.core.util.AbstractChecker<Currency,CheckerCurrency>
com.luchersol.core.specialized_checkers.CheckerCurrency
All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Currency,CheckerCurrency>,Currency>

public class CheckerCurrency extends AbstractChecker<Currency,CheckerCurrency>
A specialized checker for Currency instances, providing a fluent API to assert various currency properties such as symbol, fraction digits, and locale association.

Typical usage:


 Currency usd = Currency.getInstance("USD");

 CheckerCurrency.check(usd)
     .hasSymbol("$")
     .withDefaultFractionDigits(2)
     .isFrom(Locale.US);
 

This class supports chaining multiple assertions in a fluent style and integrates with AbstractChecker for generalized validation handling.

See Also:
  • Constructor Details

    • CheckerCurrency

      protected CheckerCurrency(Currency currency, String name)
      Constructs a new CheckerCurrency with the specified currency and name.
      Parameters:
      currency - the Currency to be associated with this checker
      name - the name of the checker
  • Method Details

    • check

      public static CheckerCurrency check(Currency currency, String name)
      Creates a new CheckerCurrency instance for the given currency and name.
      Parameters:
      currency - the currency value to be checked
      name - the name to identify the currency in error messages
      Returns:
      a CheckerCurrency instance for further validations
    • check

      public static CheckerCurrency check(Currency currency)
      Creates a new CheckerCurrency instance for the given currency with a default name.
      Parameters:
      currency - the currency value to be checked
      Returns:
      a CheckerCurrency instance for further validations
    • self

      protected CheckerCurrency self()
      Returns this instance (for fluent API usage).
      Specified by:
      self in class AbstractChecker<Currency,CheckerCurrency>
      Returns:
      this CheckerCurrency instance
    • hasSymbol

      public CheckerCurrency hasSymbol(String symbol)
      Checks if the currency has the specified symbol in the default locale.
      Parameters:
      symbol - the symbol to compare with the currency's symbol
      Returns:
      this CheckerCurrency instance for chaining
    • hasSymbol

      public CheckerCurrency hasSymbol(String symbol, Locale locale)
      Checks if the currency has the specified symbol in the given locale.
      Parameters:
      symbol - the symbol to compare with the currency's symbol
      locale - the locale to use for symbol lookup
      Returns:
      this CheckerCurrency instance for chaining
    • withDefaultFractionDigits

      public CheckerCurrency withDefaultFractionDigits(int n)
      Checks if the currency has the specified number of default fraction digits.
      Parameters:
      n - the expected number of fraction digits
      Returns:
      this CheckerCurrency instance for chaining
    • isFrom

      public CheckerCurrency isFrom(Locale locale)
      Checks if the currency is the one used in the specified locale.
      Parameters:
      locale - the locale to check against
      Returns:
      this CheckerCurrency instance for chaining