Package space.arim.dazzleconf
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 TypeMethodDescriptionGets the configuration class this factory is forGets the configuration options this factory usesload(InputStream inputStream)
Reads configuration data from an input streamload(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 channelload(ReadableByteChannel readChannel, C auxiliaryEntries)
Reads configuration data from a readable channel with the given auxiliary configuration instance.Reads the default configuration data from annotations inConfDefault
If any config entry is missing a default value annotation, or the default values cannot be deserialised to the appropriate config value,IllDefinedConfigException
is thrownvoid
write(C configData, OutputStream outputStream)
Writes configuration data to an output streamvoid
write(C configData, WritableByteChannel writableChannel)
Writes configuration data to a writable byte channel
-
Method Details
-
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 occursInvalidConfigException
- if the configuration is invalid. Where possible, more specific subclasses are thrownNullPointerException
- ifreadChannel
is null
-
load
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 occursInvalidConfigException
- if the configuration is invalid. Where possible, more specific subclasses are thrownNullPointerException
- ifinputStream
is null
-
load
C load(ReadableByteChannel readChannel, C auxiliaryEntries) throws IOException, InvalidConfigExceptionReads 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 implementsAuxiliaryKeys
, the caller can determine whether any of the auxiliary entries were used.- Parameters:
readChannel
- the channel from which to read the dataauxiliaryEntries
- the auxiliary configuration instance- Returns:
- the read config data
- Throws:
IOException
- if an I/O error occursInvalidConfigException
- if the configuration is invalid. Where possible, more specific subclasses are thrownNullPointerException
- ifreadChannel
is null
-
load
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 implementsAuxiliaryKeys
, the caller can determine whether any of the auxiliary entries were used.- Parameters:
inputStream
- the stream from which to read the dataauxiliaryEntries
- the auxiliary configuration instance- Returns:
- the read config data
- Throws:
IOException
- if an I/O error occursInvalidConfigException
- if the configuration is invalid. Where possible, more specific subclasses are thrownNullPointerException
- ifinputStream
is null
-
loadDefaults
C loadDefaults()Reads the default configuration data from annotations inConfDefault
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
Writes configuration data to a writable byte channel- Parameters:
configData
- the configuration datawritableChannel
- the channel to which to write the data- Throws:
IOException
- if an I/O error occursNullPointerException
- if either parameter is null
-
write
Writes configuration data to an output stream- Parameters:
configData
- the configuration dataoutputStream
- the stream to which to write the data- Throws:
IOException
- if an I/O error occursNullPointerException
- if either parameter is null
-