Class XmlConfigBuilderImpl

All Implemented Interfaces:
ConfigBuilder<XmlConfigBuilder>, MutableCapableConfigBuilder<XmlConfigBuilder>, XmlConfigBaseBuilder<XmlConfigBuilder>, XmlConfigBuilder

@API(status=INTERNAL, since="1.0") public class XmlConfigBuilderImpl extends AbstractConfigBuilderImpl<XmlConfigBuilder> implements XmlConfigBuilder
Implementation of XML files based configuration builder.
Since:
1.0
Version:
1.0, 2025-07
Author:
(w) Iker Hernaez
See Also:
  • Field Details

    • xmlOptions

      @NotNull protected final @NotNull XmlConfigOptions xmlOptions
      The XML based configuration options.
  • Constructor Details

    • XmlConfigBuilderImpl

      public XmlConfigBuilderImpl()
      Empty constructor.
  • Method Details

    • withSeparator

      @NotNull public @NotNull XmlConfigBuilder withSeparator(@NotEmpty @NotEmpty String separator)
      Sets the configuration nested properties separator.
      Specified by:
      withSeparator in interface XmlConfigBaseBuilder<XmlConfigBuilder>
      Parameters:
      separator - The configuration nested properties separator.
      Returns:
      This instance, for method chaining.
    • withAttributePrefix

      @NotNull public @NotNull XmlConfigBuilder withAttributePrefix(@NotEmpty @NotEmpty String prefix)
      Sets the XML attributes references prefix.
      Specified by:
      withAttributePrefix in interface XmlConfigBaseBuilder<XmlConfigBuilder>
      Parameters:
      prefix - The XML attributes references prefix.
      Returns:
      This instance, for method chaining.
    • withEmptyDocument

      @NotNull public @NotNull XmlConfigBuilder withEmptyDocument(String namespaceURI, @NotNull @NotNull String rootElementName)
      Creates an empty XML document with the specified root element name as configuration properties container.

      Note that any XML document loaded through load() methods must match the same root element name.

      Specified by:
      withEmptyDocument in interface XmlConfigBaseBuilder<XmlConfigBuilder>
      Parameters:
      namespaceURI - The XML document namespace URI.
      rootElementName - The root element name of the XML document to create.
      Returns:
      This instance, for method chaining.
    • add

      @NotNull public @NotNull XmlConfigBuilder add(@NotNull @NotNull Document values)
      Adds the specified custom properties to the configuration properties.

      Note that property keys will be processed with the configured nested properties separator.

      Specified by:
      add in interface XmlConfigBaseBuilder<XmlConfigBuilder>
      Parameters:
      values - The configuration properties.
      Returns:
      This instance, for method chaining.
    • add

      @NotNull public @NotNull XmlConfigBuilder add(@NotNull @NotNull Map<String,String> values)
      Adds the specified custom properties to the configuration properties.

      Note that an existing document is required to have been created with withEmptyDocument() or load() methtods, so that the XML document has a root element to contain the properties, and that property keys will be processed with the configured nested properties separator and attribute prefix.

      Specified by:
      add in interface XmlConfigBaseBuilder<XmlConfigBuilder>
      Parameters:
      values - The configuration properties to add.
      Returns:
      This instance, for method chaining.
    • load

      @NotNull public @NotNull XmlConfigBuilder load(@NotNull @NotNull String path)
      Loads the configuration properties from the specified ClassLoader resource.
      Specified by:
      load in interface XmlConfigBaseBuilder<XmlConfigBuilder>
      Parameters:
      path - The ClassLoader resource path.
      Returns:
      This instance, for method chaining.
    • load

      @NotNull public @NotNull XmlConfigBuilder load(@NotNull @NotNull Path path)
      Loads the configuration properties from the file in the specified path.
      Specified by:
      load in interface XmlConfigBaseBuilder<XmlConfigBuilder>
      Parameters:
      path - The file path.
      Returns:
      This instance, for method chaining.
    • load

      @NotNull public @NotNull XmlConfigBuilder load(@NotNull @NotNull File file)
      Loads the configuration properties from the specified file.
      Specified by:
      load in interface XmlConfigBaseBuilder<XmlConfigBuilder>
      Parameters:
      file - The file to load.
      Returns:
      This instance, for method chaining.
    • load

      @NotNull public @NotNull XmlConfigBuilder load(@NotNull @NotNull URL url)
      Loads the configuration properties from the specified URL.
      Specified by:
      load in interface XmlConfigBaseBuilder<XmlConfigBuilder>
      Parameters:
      url - The URL to load.
      Returns:
      This instance, for method chaining.
    • mutable

      @NotNull public @NotNull XmlMutableConfigBuilder mutable()
      Makes the configuration instance mutable.
      Specified by:
      mutable in interface MutableCapableConfigBuilder<XmlConfigBuilder>
      Specified by:
      mutable in interface XmlConfigBuilder
      Returns:
      This instance, for method chaining.
    • build

      @NotNull public @NotNull XmlConfigImpl build()
      Creates the configuration instance.
      Specified by:
      build in interface ConfigBuilder<XmlConfigBuilder>
      Returns:
      The configuration instance.