Interface ConfigurationFactory<C>

Type Parameters:
C - the type of the configuration
All Known Implementing Classes:
AbstractConfigurationFactory, BaseConfigurationFactory, ConfigurationFormatFactory, HumanReadableConfigurationFactory

public interface ConfigurationFactory<C>
Loader and writer of configuration data
Author:
A248
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the configuration class this factory is for
    Gets the configuration options this factory uses
    load​(InputStream inputStream)
    Reads configuration data from an input stream
    load​(InputStream inputStream, C auxiliaryEntries)
    Reads configuration data from an input stream with the given auxiliary configuration instance.
    load​(ReadableByteChannel readChannel)
    Reads configuration data from a readable channel
    load​(ReadableByteChannel readChannel, C auxiliaryEntries)
    Reads configuration data from a readable channel with the given auxiliary configuration instance.
    Reads the default configuration data from annotations in ConfDefault

    If any config entry is missing a default value annotation, or the default values cannot be deserialised to the appropriate config value, IllDefinedConfigException is thrown
    void
    write​(C configData, OutputStream outputStream)
    Writes configuration data to an output stream
    void
    write​(C configData, WritableByteChannel writableChannel)
    Writes configuration data to a writable byte channel
  • Method Details

    • getConfigClass

      Class<C> getConfigClass()
      Gets the configuration class this factory is for
      Returns:
      the configuration class
    • getOptions

      ConfigurationOptions getOptions()
      Gets the configuration options this factory uses
      Returns:
      the configuration options
    • load

      Reads configuration data from a readable channel
      Parameters:
      readChannel - the channel from which to read the data
      Returns:
      the read config data
      Throws:
      IOException - if an I/O error occurs
      InvalidConfigException - if the configuration is invalid. Where possible, more specific subclasses are thrown
      NullPointerException - if readChannel is null
    • load

      C load(InputStream inputStream) throws IOException, InvalidConfigException
      Reads configuration data from an input stream
      Parameters:
      inputStream - the stream from which to read the data
      Returns:
      the read config data
      Throws:
      IOException - if an I/O error occurs
      InvalidConfigException - if the configuration is invalid. Where possible, more specific subclasses are thrown
      NullPointerException - if inputStream is null
    • load

      C load(ReadableByteChannel readChannel, C auxiliaryEntries) throws IOException, InvalidConfigException
      Reads configuration data from a readable channel with the given auxiliary configuration instance. Any keys missing in the loaded config data will be supplanted by the config instance's corresponding entry.

      By checking if the returned configuration implements AuxiliaryKeys, the caller can determine whether any of the auxiliary entries were used.
      Parameters:
      readChannel - the channel from which to read the data
      auxiliaryEntries - the auxiliary configuration instance
      Returns:
      the read config data
      Throws:
      IOException - if an I/O error occurs
      InvalidConfigException - if the configuration is invalid. Where possible, more specific subclasses are thrown
      NullPointerException - if readChannel is null
    • load

      C load(InputStream inputStream, C auxiliaryEntries) throws IOException, InvalidConfigException
      Reads configuration data from an input stream with the given auxiliary configuration instance. Any keys missing in the loaded config data will be supplanted by the config instance's corresponding entry.

      By checking if the returned configuration implements AuxiliaryKeys, the caller can determine whether any of the auxiliary entries were used.
      Parameters:
      inputStream - the stream from which to read the data
      auxiliaryEntries - the auxiliary configuration instance
      Returns:
      the read config data
      Throws:
      IOException - if an I/O error occurs
      InvalidConfigException - if the configuration is invalid. Where possible, more specific subclasses are thrown
      NullPointerException - if inputStream is null
    • loadDefaults

      C loadDefaults()
      Reads the default configuration data from annotations in ConfDefault

      If any config entry is missing a default value annotation, or the default values cannot be deserialised to the appropriate config value, IllDefinedConfigException is thrown
      Returns:
      the read config data
      Throws:
      IllDefinedConfigException - if the defaults are not defined or ill defined
    • write

      void write(C configData, WritableByteChannel writableChannel) throws IOException
      Writes configuration data to a writable byte channel
      Parameters:
      configData - the configuration data
      writableChannel - the channel to which to write the data
      Throws:
      IOException - if an I/O error occurs
      NullPointerException - if either parameter is null
    • write

      void write(C configData, OutputStream outputStream) throws IOException
      Writes configuration data to an output stream
      Parameters:
      configData - the configuration data
      outputStream - the stream to which to write the data
      Throws:
      IOException - if an I/O error occurs
      NullPointerException - if either parameter is null