Class LocalizedExceptionBuilder<T extends LocalizedExceptionBuilder<T>>

java.lang.Object
jdk.jpackage.internal.util.LocalizedExceptionBuilder<T>
Type Parameters:
T - Subclass extending LocalizedExceptionBuilder class.
Direct Known Subclasses:
ConfigException.Builder

public class LocalizedExceptionBuilder<T extends LocalizedExceptionBuilder<T>> extends Object
Builder of exceptions with localized messages.
  • Constructor Details

    • LocalizedExceptionBuilder

      protected LocalizedExceptionBuilder(StringBundle i18n)
  • Method Details

    • buildLocalizedException

      public static LocalizedExceptionBuilder<?> buildLocalizedException(StringBundle i18n)
      Creates an exception builder with the given source of error messages.
      Parameters:
      i18n - the source of error messages
      Returns:
      the exception builder
    • create

      public final <U extends Exception> U create(BiFunction<String,Throwable,U> exceptionCtor)
      Creates an instance of type extending Exception class from the configured message and cause.

      Use message(String, Object...), causeAndMessage(Throwable), and cause(Throwable) methods to initialize message and/or cause.

      Type Parameters:
      U - the exception class
      Parameters:
      exceptionCtor - the exception constructor
      Returns:
      the exception
    • format

      public final T format(boolean v)
      Configures this builder if strings from the associated string bundle should be used as patterns for message formatting or not. Affects the behavior of the subsequent message(String, Object...) calls.
      Parameters:
      v - true if strings from the associated string bundle should be used as patterns for message formatting by this builder or false otherwise
      Returns:
      this
      See Also:
    • noformat

      public final T noformat()
      A shortcut for format(false) call.
      Returns:
      this
      See Also:
    • message

      public final T message(String msgId, Object... args)
      Sets the message.
      Parameters:
      msgId - key of the string in the associated string bundle for the formatting pattern
      args - the arguments for formatting message
      Returns:
      this
    • cause

      public final T cause(Throwable v)
      Sets the cause.
      Parameters:
      v - the cause. A null value is permitted, and indicates that the cause is nonexistent or unknown.
      Returns:
      this
    • causeAndMessage

      public final T causeAndMessage(Throwable t)
      Sets the cause and the message. The message is copied from the given Throwable object as is.
      Parameters:
      t - the cause. Must not be null.
      Returns:
      this
    • formatString

      protected final String formatString(String keyId, Object... args)