Class AbstractXmlStream<T>

java.lang.Object
io.jenkins.plugins.util.AbstractXmlStream<T>
Type Parameters:
T - type of the entities

public abstract class AbstractXmlStream<T> extends Object
Base class that provides the basic setup to read and write entities of a given type using XStream.
Author:
Ullrich Hafner
  • Constructor Details

    • AbstractXmlStream

      protected AbstractXmlStream(Class<T> type)
      Creates a new instance of AbstractXmlStream.
      Parameters:
      type - the type of the elements that are stored and retrieved
  • Method Details

    • createDefaultValue

      protected abstract T createDefaultValue()
      Returns the default value that should be returned if the XML file is broken.
      Returns:
      the default value
    • configureXStream

      protected void configureXStream(XStream2 xStream)
      Configures the XStream instance with custom converters or alias definitions. This default implementation is empty.
      Parameters:
      xStream - the XStream instance
    • read

      public T read(Path file)
      Reads the specified file and creates a new instance of the given type.
      Parameters:
      file - path to the file
      Returns:
      the created instance
    • write

      public void write(Path file, T entity)
      Writes the specified instance to the given file.
      Parameters:
      file - path to the file
      entity - the entity to write to the file