Package io.jenkins.plugins.util
Class AbstractXmlStream<T>
java.lang.Object
io.jenkins.plugins.util.AbstractXmlStream<T>
- Type Parameters:
T
- type of the entities
Base class that provides the basic setup to read and write entities of a given type using
XStream
.- Author:
- Ullrich Hafner
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractXmlStream
(Class<T> type) Creates a new instance ofAbstractXmlStream
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureXStream
(XStream2 xStream) Configures theXStream
instance with custom converters or alias definitions.protected abstract T
Returns the default value that should be returned if the XML file is broken.Reads the specifiedfile
and creates a new instance of the given type.void
Writes the specified instance to the givenfile
.
-
Constructor Details
-
AbstractXmlStream
Creates a new instance ofAbstractXmlStream
.- Parameters:
type
- the type of the elements that are stored and retrieved
-
-
Method Details
-
createDefaultValue
Returns the default value that should be returned if the XML file is broken.- Returns:
- the default value
-
configureXStream
Configures theXStream
instance with custom converters or alias definitions. This default implementation is empty.- Parameters:
xStream
- theXStream
instance
-
read
Reads the specifiedfile
and creates a new instance of the given type.- Parameters:
file
- path to the file- Returns:
- the created instance
-
write
Writes the specified instance to the givenfile
.- Parameters:
file
- path to the fileentity
- the entity to write to the file
-