Class BaseConfigurationFactory<C>

java.lang.Object
space.arim.dazzleconf.factory.BaseConfigurationFactory<C>
Type Parameters:
C - the type of the configuration
All Implemented Interfaces:
ConfigurationFactory<C>

@Deprecated public abstract class BaseConfigurationFactory<C> extends Object implements ConfigurationFactory<C>
Deprecated.
Will be removed without replacement in a later release. Contributes little value on its own.
Basic abstract implementation of of ConfigurationFactory. Eliminates some basic boilerplate associated with IO operations.
Author:
A248
  • Constructor Details

    • BaseConfigurationFactory

      protected BaseConfigurationFactory(Class<C> configClass, ConfigurationOptions options)
      Deprecated.
      Creates from a config class and config options
      Parameters:
      configClass - the config class
      options - configuration options
      Throws:
      NullPointerException - if configClass or options is null
      IllegalArgumentException - if configClass is not an interface
  • Method Details

    • getConfigClass

      public Class<C> getConfigClass()
      Deprecated.
      Description copied from interface: ConfigurationFactory
      Gets the configuration class this factory is for
      Specified by:
      getConfigClass in interface ConfigurationFactory<C>
      Returns:
      the configuration class
    • getOptions

      public ConfigurationOptions getOptions()
      Deprecated.
      Description copied from interface: ConfigurationFactory
      Gets the configuration options this factory uses
      Specified by:
      getOptions in interface ConfigurationFactory<C>
      Returns:
      the configuration options
    • charset

      protected abstract Charset charset()
      Deprecated.
      The charset used by this factory
      Returns:
      the charset to use
    • loadFromReader

      protected abstract C loadFromReader(Reader reader) throws IOException, InvalidConfigException
      Deprecated.
      Reads config data from the specified reader
      Parameters:
      reader - the stream reader
      Returns:
      the config data
      Throws:
      IOException - if an I/O error occurs
      InvalidConfigException - if the configuration is not valid
    • loadFromReader

      protected abstract C loadFromReader(Reader reader, C auxiliaryEntries) throws IOException, InvalidConfigException
      Deprecated.
      Reads config data from the specified reader with the given auxiliary entries. The auxiliary entries are the same ones passed to ConfigurationFactory
      Parameters:
      reader - the stream reader
      auxiliaryEntries - the auxiliary entries
      Returns:
      the config data
      Throws:
      IOException - if an I/O error occurs
      InvalidConfigException - if the configuration is not valid
    • load

      public C load(ReadableByteChannel readChannel) throws IOException, InvalidConfigException
      Deprecated.
      Description copied from interface: ConfigurationFactory
      Reads configuration data from a readable channel
      Specified by:
      load in interface ConfigurationFactory<C>
      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
    • load

      public C load(InputStream inputStream) throws IOException, InvalidConfigException
      Deprecated.
      Description copied from interface: ConfigurationFactory
      Reads configuration data from an input stream
      Specified by:
      load in interface ConfigurationFactory<C>
      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
    • load

      public C load(ReadableByteChannel readChannel, C auxiliaryEntries) throws IOException, InvalidConfigException
      Deprecated.
      Description copied from interface: ConfigurationFactory
      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.
      Specified by:
      load in interface ConfigurationFactory<C>
      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
    • load

      public C load(InputStream inputStream, C auxiliaryEntries) throws IOException, InvalidConfigException
      Deprecated.
      Description copied from interface: ConfigurationFactory
      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.
      Specified by:
      load in interface ConfigurationFactory<C>
      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
    • writeToWriter

      protected abstract void writeToWriter(C configData, Writer writer) throws IOException
      Deprecated.
      Writes config data to the specified writer
      Parameters:
      configData - the configuration data to write
      writer - the stream writer
      Throws:
      IOException - if an I/O error occurs
    • write

      public void write(C configData, WritableByteChannel writableChannel) throws IOException
      Deprecated.
      Description copied from interface: ConfigurationFactory
      Writes configuration data to a writable byte channel
      Specified by:
      write in interface ConfigurationFactory<C>
      Parameters:
      configData - the configuration data
      writableChannel - the channel to which to write the data
      Throws:
      IOException - if an I/O error occurs
    • write

      public void write(C configData, OutputStream outputStream) throws IOException
      Deprecated.
      Description copied from interface: ConfigurationFactory
      Writes configuration data to an output stream
      Specified by:
      write in interface ConfigurationFactory<C>
      Parameters:
      configData - the configuration data
      outputStream - the stream to which to write the data
      Throws:
      IOException - if an I/O error occurs