Package fileLogic

Class Loader<T extends Collection<E>,E>

java.lang.Object
fileLogic.Loader<T,E>
Type Parameters:
T - Collection to fill
E - Type of collection elements

public class Loader<T extends Collection<E>,E> extends Object
Abstract loader class. It uses java.lang.reflect API for changing fields taken from XML file and converted by java.beans.PropertyEditor. It fills Elements of type E to collection of type T
Since:
1.0
See Also:
  • Constructor Details

    • Loader

      public Loader(Class<T> tClass, Class<E> eClass)
      Initializer of fileLogic.Loader class.
      Parameters:
      tClass - Class of T. Should be provided due to Java's generic types restriction.
      eClass - Class of E. Should be provided due to Java's generic types restriction.
  • Method Details

    • setupConverter

      public static void setupConverter(Class<?> typeToEdit, Class<? extends PropertyEditor> editor)
      Manually register editor for your datatype. Call this method before parsing XML.
      Parameters:
      typeToEdit - Type to register in editor
      editor - Editor of type. Should implement PropertyEditor interface
      See Also:
    • loadFromXMLbyEnvKey

      public T loadFromXMLbyEnvKey(String envKey)
      Fill collection with elements from XML file. XML filepath will be taken from Environment variable
      Parameters:
      envKey - Key of System env. var to XML filepath
      Returns:
      Filled collection of type T
    • loadFromFile

      public T loadFromFile(String path, BaseReader reader)
      Abstract method to read any collection from any file by any reader.
      Parameters:
      path - Path to file
      reader - File reader
      Returns:
      Collection with elements matched by file