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
ConstructorsModifierConstructorDescriptionprotectedAbstractXmlStream(Class<T> type) Creates a new instance ofAbstractXmlStream. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigureXStream(XStream2 xStream) Configures theXStreaminstance with custom converters or alias definitions.protected abstract TReturns the default value that should be returned if the XML file is broken.protected final XStream2Reads the specifiedfileand creates a new instance of the given type.voidWrites 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
-
createStream
-
configureXStream
Configures theXStreaminstance with custom converters or alias definitions. This default implementation is empty.- Parameters:
xStream- theXStreaminstance
-
read
Reads the specifiedfileand 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
-