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 theMapper
interface specifically forSUL
s.SULMappers, like
SUL
s, 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 boolean
canFork()
Checks whether it is possible tofork
this 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 unwrappedRuntimeException
to an abstract output symbol, or rethrows it if it is unmappable.default MappedException<? extends AO>
mapWrappedException(SULException exception)
Maps a wrappedSULException
to an abstract output symbol, or rethrows it if it is unmappable.
-
-
-
Method Detail
-
canFork
default boolean canFork()
Checks whether it is possible tofork
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()
returnedfalse
, this method must throw anUnsupportedOperationException
. 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 wrappedSULException
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 unwrappedRuntimeException
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 exceptionRuntimeException
- if the given exception cannot be mapped, or if a new exception occurs while trying to map the given exception
-
-