Class LocaleExpressionVariable

java.lang.Object
com.broadleafcommerce.rulesengine.expression.util.LocaleExpressionVariable
All Implemented Interfaces:
ExpressionVariable

public class LocaleExpressionVariable extends Object implements ExpressionVariable

Common operations for locale comparison

The methods in this class expect the compared locale to be in either IETF (with dash, i.e., "en-US"), POSIX (with underscore, i.e., "en_US"), or simply the language, i.e., "en".

An instance of this class will usually be accessible as a variable within an expression via #locales.

Author:
Chad Harchar (charchar)
  • Field Details

  • Constructor Details

    • LocaleExpressionVariable

      public LocaleExpressionVariable()
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface ExpressionVariable
      Returns:
      Name of the variable, must not be null
    • equals

      public final boolean equals(@Nullable Locale locale, String localeString)
      Checks if locales are equal.
      Parameters:
      locale - the locale to be compared
      localeString - the locale in IETF or POSIX to compare to
      Returns:
      true if locale is equal to the specified localeString
    • notEquals

      public final boolean notEquals(@Nullable Locale locale, String localeString)
      Checks if locales are not equal.
      Parameters:
      locale - the locale to be compared
      localeString - the locale in IETF or POSIX to compare to
      Returns:
      true if locale is not equal to the specified localeString
    • contains

      public final boolean contains(@Nullable Locale locale, String localeString)
      Checks if locales contains a string. Useful to check for a country or language code.
      Parameters:
      locale - the locale to be compared
      localeString - the locale in IETF or POSIX to compare to
      Returns:
      true if locale contains the specified localeString