Package com.oorian.i18n
Class DefaultMessages
java.lang.Object
com.oorian.i18n.DefaultMessages
- All Implemented Interfaces:
MessageResolver
Default English messages for all built-in validators.
Provides message key constants and their English default templates. This class serves
as the fallback MessageResolver when no custom resolver is configured, and as the
reference for all message keys used by the validation framework.
Message keys follow the convention:
validation.<validator>— simple validators with a single messagevalidation.<validator>.<variant>— validators with multiple message variants
Named parameters use {name} placeholders in templates:
DefaultMessages resolver = new DefaultMessages();
resolver.resolve(DefaultMessages.LENGTH_BETWEEN, "min", 3, "max", 10);
// → "Must be between 3 and 10 characters"
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAll()Returns an unmodifiable map of all default message templates.static StringgetTemplate(String key) Returns the default English template for the given message key.Resolves a message by looking up its English default template and substituting parameters.
-
Field Details
-
REQUIRED
- See Also:
-
EMAIL
- See Also:
-
URL
- See Also:
-
PHONE
- See Also:
-
NUMERIC
- See Also:
-
ALPHANUMERIC
- See Also:
-
CREDIT_CARD
- See Also:
-
DATE
- See Also:
-
PATTERN
- See Also:
-
LENGTH_EXACT
- See Also:
-
LENGTH_BETWEEN
- See Also:
-
LENGTH_MIN
- See Also:
-
LENGTH_MAX
- See Also:
-
RANGE_BETWEEN
- See Also:
-
RANGE_MIN
- See Also:
-
RANGE_MAX
- See Also:
-
COMPARE_EQUALS
- See Also:
-
COMPARE_NOT_EQUALS
- See Also:
-
COMPARE_LESS_THAN
- See Also:
-
COMPARE_LESS_THAN_OR_EQUALS
- See Also:
-
COMPARE_GREATER_THAN
- See Also:
-
COMPARE_GREATER_THAN_OR_EQUALS
- See Also:
-
DATE_RANGE
- See Also:
-
-
Constructor Details
-
DefaultMessages
public DefaultMessages()Creates a new default messages resolver.
-
-
Method Details
-
getTemplate
Returns the default English template for the given message key.- Parameters:
key- the message key- Returns:
- the template string, or
nullif the key is not recognized
-
getAll
Returns an unmodifiable map of all default message templates.- Returns:
- all message keys and their English templates
-
resolve
Resolves a message by looking up its English default template and substituting parameters.- Specified by:
resolvein interfaceMessageResolver- Parameters:
key- the message keyparams- alternating key-value pairs for parameter substitution- Returns:
- the resolved message, or the key itself if not found
-