Class LocaleExpressionVariable
java.lang.Object
com.broadleafcommerce.rulesengine.expression.util.LocaleExpressionVariable
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Checks if locales contains a string.final boolean
Checks if locales are equal.getName()
final boolean
Checks if locales are not equal.
-
Field Details
-
NAME
- See Also:
-
-
Constructor Details
-
LocaleExpressionVariable
public LocaleExpressionVariable()
-
-
Method Details
-
getName
- Specified by:
getName
in interfaceExpressionVariable
- Returns:
- Name of the variable, must not be null
-
equals
Checks if locales are equal.- Parameters:
locale
- the locale to be comparedlocaleString
- the locale in IETF or POSIX to compare to- Returns:
- true if locale is equal to the specified localeString
-
notEquals
Checks if locales are not equal.- Parameters:
locale
- the locale to be comparedlocaleString
- the locale in IETF or POSIX to compare to- Returns:
- true if locale is not equal to the specified localeString
-
contains
Checks if locales contains a string. Useful to check for a country or language code.- Parameters:
locale
- the locale to be comparedlocaleString
- the locale in IETF or POSIX to compare to- Returns:
- true if locale contains the specified localeString
-