Class MappingLoaders

java.lang.Object
org.openehealth.ipf.commons.map.MappingLoaders

public final class MappingLoaders extends Object
Discovery of MappingLoader implementations through ServiceLoader.
Since:
6.0
  • Method Details

    • discover

      public static List<MappingLoader> discover()
      Returns:
      all loaders visible to the current thread's context class loader, falling back to the class loader of this class
    • forSource

      public static Optional<MappingLoader> forSource(URI source)
      Parameters:
      source - a mapping source location
      Returns:
      the first discovered loader that supports the given source
    • forFormat

      public static Optional<MappingLoader> forFormat(String format)
      Parameters:
      format - a format id, compared case-insensitively
      Returns:
      the loader reading that format, empty if none on the classpath does
      Throws:
      IllegalStateException - if several loaders claim the same format id, since picking one of them would be arbitrary
    • formats

      public static Set<String> formats()
      Returns:
      the format ids that can currently be read, for diagnostics
    • resolve

      public static MappingLoader resolve(URI source, String format)
      Picks the loader for a source: the one named by format if there is one, and otherwise the one claiming the source's file extension. This is the single place where that precedence is decided - an explicitly named format always wins, which is what lets a source whose name says nothing about its format be read at all.
      Parameters:
      source - a mapping source location
      format - a format id, or null to dispatch by file extension
      Returns:
      the loader to read the source with
      Throws:
      MappingException - if no loader on the classpath can read it