Class ValidationContext

java.lang.Object
com.winterhavenmc.library.messagebuilder.validation.ValidationContext

public final class ValidationContext extends Object
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 Details

    • initialize

      public static void initialize(LocaleProvider provider)
      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

      public static Locale getLocale()
      Returns the current locale used for formatting validation messages. If the context has not been initialized, falls back to Locale.getDefault().
      Returns:
      the active validation locale