Class ValidationContext
java.lang.Object
com.winterhavenmc.library.messagebuilder.validation.ValidationContext
Provides global access to the plugin-configured locale used
during validation message formatting.
This singleton must be explicitly initialized during plugin startup
using initialize(LocaleProvider)
. After initialization,
the locale is considered immutable.
Validation logic (e.g., Validator
) uses this context
to format localized error messages.
Note: The reset()
method is intended for use
in unit tests only and should never be called during normal plugin execution.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Locale
Returns the current locale used for formatting validation messages.static void
initialize
(LocaleProvider provider) Initializes the validation context with the provided locale source.
-
Method Details
-
initialize
Initializes the validation context with the provided locale source.This method should be called exactly once during plugin startup. Subsequent calls will throw an
IllegalStateException
.- Parameters:
provider
- the plugin’s configured locale provider- Throws:
IllegalStateException
- if already initialized
-
getLocale
Returns the current locale used for formatting validation messages. If the context has not been initialized, falls back toLocale.getDefault()
.- Returns:
- the active validation locale
-