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 theMapperinterface specifically forSULs.SULMappers, like
SULs, may beforkable. The requirements and semantics offork()are basically the same as set forth forSUL.fork(). Stateless mappers (e.g., with emptyMapper.pre()andMapper.post()implementations), should always be forkable, andfork()may just returnthis. 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()andfork()indicate non-forkability for backwards compatibility reasons.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default booleancanFork()Checks whether it is possible toforkthis mapper.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.default MappedException<? extends AO>mapUnwrappedException(RuntimeException exception)Maps an unwrappedRuntimeExceptionto an abstract output symbol, or rethrows it if it is unmappable.default MappedException<? extends AO>mapWrappedException(SULException exception)Maps a wrappedSULExceptionto an abstract output symbol, or rethrows it if it is unmappable.
-
-
-
Method Detail
-
canFork
default boolean canFork()
Checks whether it is possible toforkthis mapper.- Returns:
trueif this mapper can be forked,falseotherwise.
-
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()returnedfalse, this method must throw anUnsupportedOperationException. Otherwise, it must return a non-nullobject representing the fork of this mapper.- Returns:
- a fork of this mapper (for stateless mappers, generally
thisshould be returned) - Throws:
UnsupportedOperationException- if this mapper is not forkable
-
mapWrappedException
default MappedException<? extends AO> mapWrappedException(SULException exception)
Maps a wrappedSULExceptionto 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 unwrappedRuntimeExceptionto 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 exceptionRuntimeException- if the given exception cannot be mapped, or if a new exception occurs while trying to map the given exception
-
-