Class 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.
    Ullrich Hafner
    • Constructor Detail

      • AbstractXmlStream

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

      • createDefaultValue

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

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

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

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