Class MappingLoaders
java.lang.Object
org.openehealth.ipf.commons.map.MappingLoaders
Discovery of
MappingLoader implementations through ServiceLoader.- Since:
- 6.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<MappingLoader> discover()static Optional<MappingLoader> formats()static Optional<MappingLoader> static MappingLoaderPicks the loader for a source: the one named byformatif there is one, and otherwise the one claiming the source's file extension.
-
Method Details
-
discover
- Returns:
- all loaders visible to the current thread's context class loader, falling back to the class loader of this class
-
forSource
- Parameters:
source- a mapping source location- Returns:
- the first discovered loader that supports the given source
-
forFormat
- Parameters:
format- aformat 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
-
resolve
Picks the loader for a source: the one named byformatif 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 locationformat- aformat id, ornullto dispatch by file extension- Returns:
- the loader to read the source with
- Throws:
MappingException- if no loader on the classpath can read it
-