Package dev.orne.i18n

Class I18nResourcesString.Builder

java.lang.Object
dev.orne.i18n.I18nResourcesString.Builder
Enclosing class:
I18nResourcesString

@API(status=STABLE, since="0.1") public static class I18nResourcesString.Builder extends Object
Builder of I18nResourcesString instances.
Since:
0.1
Version:
1.0, 2021-01
Author:
(w) Iker Hernaez
  • Constructor Details

    • Builder

      public Builder(@NotNull @NotNull String defaultText)
      Creates a new I18nResourcesString builder with the specified default text.
      Parameters:
      defaultText - The default text
  • Method Details

    • ofResources

      public I18nResourcesString.Builder ofResources(String key)
      Sets the I18N resources to use. If null will use default ones.
      Parameters:
      key - The I18N resources to use
      Returns:
      This builder for method chaining
    • withCode

      public I18nResourcesString.Builder withCode(@NotNull @NotNull String code)
      Appends the specified text code to the codes configured of this builder.
      Parameters:
      code - The I18N text code
      Returns:
      This builder for method chaining
    • withCodes

      public I18nResourcesString.Builder withCodes(@NotNull @NotNull String... codes)
      Appends the specified text codes to the codes configured of this builder. No null codes are allowed.
      Parameters:
      codes - The I18N text codes, in order of priority
      Returns:
      This builder for method chaining
    • withArg

      Adds the specified argument to the text arguments of this builder.
      Parameters:
      arg - The text argument, applied to resolved or default text
      Returns:
      This builder for method chaining
    • withArgs

      public I18nResourcesString.Builder withArgs(Serializable... args)
      Adds the specified arguments to the text arguments of this builder.
      Parameters:
      args - The text arguments, applied to resolved text or default text
      Returns:
      This builder for method chaining
    • getI18nResourcesKey

      protected String getI18nResourcesKey()
      Returns the key of the I18N resources to use.
      Returns:
      The key of the I18N resources to use
    • getDefaultText

      protected String getDefaultText()
      Returns the default text.
      Returns:
      The default text
    • getCodes

      protected List<String> getCodes()
      Returns the I18N text codes, in order of priority.
      Returns:
      The I18N text codes, in order of priority
    • getArguments

      protected List<Serializable> getArguments()
      Returns the text arguments, applied to resolved or default text.
      Returns:
      The text arguments
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • build

      public I18nResourcesString build()
      Builds a I18nResourcesString with the configured properties. Validates that the default text and that at least one text code are set.
      Returns:
      The I18nResourcesString with the configured properties