Interface ParsableSource

All Superinterfaces:
Source
All Known Implementing Classes:
ClasspathConfigSource, EtcdConfigSource, FileConfigSource, GitConfigSource, UrlConfigSource

public interface ParsableSource extends Source
An eager source that can read all data from the underlying origin as a stream that can be parsed based on its media type (or using an explicit ConfigParser.
  • Method Details

    • load

      Loads the underlying source data. This method is only called when the source Source.exists().

      The method can be invoked repeatedly, for example during retries. In case the underlying data is gone or does not exist, return an empty optional.

      Returns:
      An instance of T as read from the underlying origin of the data (if it exists)
      Throws:
      ConfigException - in case of errors loading from the underlying origin
    • parser

      If a parser is configured with this source, return it. The source implementation does not need to handle config parser.
      Returns:
      content parser if one is configured on this source
    • mediaType

      Optional<String> mediaType()
      If media type is configured on this source, or can be guessed from the underlying origin, return it. The media type may be used to locate a ConfigParser if one is not explicitly configured.
      Returns:
      media type if configured or detected from content
    • relativeResolver

      default Function<String,Optional<InputStream>> relativeResolver()
      Resolve relative resource to the current resource.
      Returns:
      a function to resolve resource name into an input stream