java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.util.FileCache<T>
Type Parameters:
T - the type of object to store.

public class FileCache<T> extends Object
File cache which can be used to store a java object in a file and load it from that file if the program runs a second time.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • file

      protected File file
    • instance

      protected T instance
  • Constructor Details

    • FileCache

      public FileCache(String file, Supplier<T> instanceSuplier)
    • FileCache

      public FileCache(File file, Supplier<T> instanceSuplier)
    • FileCache

      public FileCache(String file)
    • FileCache

      public FileCache(File file)
  • Method Details

    • loadFromFileOrUseSuplier

      public T loadFromFileOrUseSuplier(Supplier<T> instanceSuplier)
    • load

      private void load(Supplier<T> instanceSuplier)
    • get

      public T get()
      Returns the instance which can be cached in file.
      Returns:
      the instance
    • saveAtShutdown

      public void saveAtShutdown()
      Save instance to file when JVM terminates. Call this function only once.
    • saveAtShutdownIfCacheNotExistent

      public void saveAtShutdownIfCacheNotExistent()
      Save instance to file when JVM terminates but only if cache file does not exists. Call this function only once.
    • save

      public void save()
      Save instance to file now.
    • saveIfCacheNotExistent

      public void saveIfCacheNotExistent()
      Save instance to file now but only if cache file is not existent.
    • getFile

      public File getFile()