Class SupportedFileFormats<T extends FileFormat>

java.lang.Object
com.stardog.stark.io.SupportedFileFormats<T>

public final class SupportedFileFormats<T extends FileFormat> extends Object

Utility class to keep a list of formats that are supported by an application.

Since:
1.0
Version:
1.0
Author:
Michael Grove
  • Constructor Details

    • SupportedFileFormats

      public SupportedFileFormats()
    • SupportedFileFormats

      protected SupportedFileFormats(Set<T> theFormats, Map<String,T> theAliases)
  • Method Details

    • add

      @Nonnull public SupportedFileFormats<T> add(@Nonnull T theFormat)
      Add a new format to the list of supported formats
      Parameters:
      theFormat - the format to add
    • contains

      public boolean contains(@Nonnull T theFormat)
      Return whether or not the specific format is supported
      Parameters:
      theFormat - the format
      Returns:
      `true` if supported, `false` otherwise
    • alias

      public SupportedFileFormats<T> alias(@Nonnull String theAlias, @Nonnull T theFormat)
      Associate an alias for the given format
      Parameters:
      theAlias - the alias
      theFormat - the format
    • forFile

      @Nonnull public Optional<T> forFile(@Nonnull Path thePath)
      Return the format for the file denoted by the given Path.
      Parameters:
      thePath - the file to be parsed
      Returns:
      the format
      Implementation Notes:
      This will inspect the file extension of the path and attempt to align it with the file extensions registered with all known formats. The default extensions are checked first before all other extensions are checked.
    • forFileName

      @Nonnull public Optional<T> forFileName(@Nonnull String thePath)
    • forName

      @Nonnull public Optional<T> forName(@Nonnull String theName)
      Return the format with the provided name.
      Parameters:
      theName - the name of the format
      Returns:
      the format
      Implementation Notes:
      Format names, and function inputs, are normalized to all caps before matching and a small set of common aliases are used.
    • forMime

      @Nonnull public Optional<T> forMime(@Nonnull String theMime)
      Return the format which supports the given mimetype
      Parameters:
      theMime - the mimetype
      Returns:
      the format that supports the mimetype
      Implementation Notes:
      The default mimetypes are checked for _all_ formats before the full set of mimetypes for each format are considered.
    • only

      @Nonnull public SupportedFileFormats<T> only(@Nonnull Predicate<T> thePredicate)
      Return a new SupportedFileFormats which contains only the formats which match the given predicate
      Parameters:
      thePredicate - the predicate for filtering
      Returns:
      the new `SupportedFileFormats`
    • forEach

      public void forEach(@Nonnull Consumer<T> theConsumer)