Interface SULMapper<AI,​AO,​CI,​CO>

  • Type Parameters:
    AI - abstract input symbol type.
    AO - abstract output symbol type.
    CI - concrete input symbol type.
    CO - concrete output symbol type.
    All Superinterfaces:
    Mapper<AI,​AO,​CI,​CO>, Mapper.SynchronousMapper<AI,​AO,​CI,​CO>
    All Known Implementing Classes:
    SimplePOJOExceptionMapper, StringMapper

    public interface SULMapper<AI,​AO,​CI,​CO>
    extends Mapper.SynchronousMapper<AI,​AO,​CI,​CO>
    An extension of the Mapper interface specifically for SULs.

    SULMappers, like SULs, may be forkable. The requirements and semantics of fork() are basically the same as set forth for SUL.fork(). Stateless mappers (e.g., with empty Mapper.pre() and Mapper.post() implementations), should always be forkable, and fork() may just return this. Stateful mappers may require more sophisticated fork logic, but in general it should be possible to fork them as well.

    Note: despite the above recommendation that mappers should almost always be forkable, the default implementations of canFork() and fork() indicate non-forkability for backwards compatibility reasons.

    • Method Detail

      • canFork

        default boolean canFork()
        Checks whether it is possible to fork this mapper.
        Returns:
        true if this mapper can be forked, false otherwise.
      • fork

        default SULMapper<AI,​AO,​CI,​CO> fork()
        Forks this mapper, i.e., returns a mapper that behaves in exactly the same way as this mapper, but allows for being used independently of this mapper.

        If canFork() returned false, this method must throw an UnsupportedOperationException. Otherwise, it must return a non-null object representing the fork of this mapper.

        Returns:
        a fork of this mapper (for stateless mappers, generally this should be returned)
        Throws:
        UnsupportedOperationException - if this mapper is not forkable
      • mapWrappedException

        default MappedException<? extends AO> mapWrappedException​(SULException exception)
        Maps a wrapped SULException to an abstract output symbol, or rethrows it if it is unmappable.
        Parameters:
        exception - the wrapped exception that was thrown
        Returns:
        the concrete output symbol the exception was mapped to, if applicable
        Throws:
        SULException - if the exception cannot be mapped, or if a new exception occurs while trying to map the given exception
      • mapUnwrappedException

        default MappedException<? extends AO> mapUnwrappedException​(RuntimeException exception)
        Maps an unwrapped RuntimeException to an abstract output symbol, or rethrows it if it is unmappable.
        Parameters:
        exception - the runtime exception that was thrown
        Returns:
        the concrete output symbol the exception was mapped to, if applicable
        Throws:
        SULException - if a new exception occurs while trying to map the given exception
        RuntimeException - if the given exception cannot be mapped, or if a new exception occurs while trying to map the given exception