Package org.jdbi.v3.core.interceptor
Class JdbiInterceptionChainHolder<S,T>
- java.lang.Object
-
- org.jdbi.v3.core.interceptor.JdbiInterceptionChainHolder<S,T>
-
- Type Parameters:
S- Type of the transformation source.T- Type of the transformation target.
@Alpha public final class JdbiInterceptionChainHolder<S,T> extends java.lang.Object
An interception chain holder to manage transformation operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classJdbiInterceptionChainHolder.ChainInstance
-
Field Summary
Fields Modifier and Type Field Description private static java.util.function.Function<?,?>DEFAULT_TRANSFORMERprivate java.util.function.Function<S,T>defaultTransformerprivate java.util.List<JdbiInterceptor<S,T>>interceptors
-
Constructor Summary
Constructors Constructor Description JdbiInterceptionChainHolder()Creates a new chain holder.JdbiInterceptionChainHolder(java.util.function.Function<S,T> defaultTransformer)Creates a new chain holder with a default interceptor.JdbiInterceptionChainHolder(JdbiInterceptionChainHolder<S,T> that)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFirst(JdbiInterceptor<S,T> interceptor)Registers a new interceptor at the beginning of the chain.voidaddLast(JdbiInterceptor<S,T> interceptor)Registers a new interceptor at the end of the chain.Tprocess(S source)Processes a source object and returns a target object.
-
-
-
Field Detail
-
DEFAULT_TRANSFORMER
private static final java.util.function.Function<?,?> DEFAULT_TRANSFORMER
-
interceptors
private final java.util.List<JdbiInterceptor<S,T>> interceptors
-
-
Constructor Detail
-
JdbiInterceptionChainHolder
public JdbiInterceptionChainHolder(java.util.function.Function<S,T> defaultTransformer)
Creates a new chain holder with a default interceptor.- Parameters:
defaultTransformer- A default interceptor that is used when no other registered interceptor processes a source object. Must not be null.
-
JdbiInterceptionChainHolder
public JdbiInterceptionChainHolder()
Creates a new chain holder. ThrowsUnsupportedOperationExceptionif no registered interceptor processes a source object.
-
JdbiInterceptionChainHolder
public JdbiInterceptionChainHolder(JdbiInterceptionChainHolder<S,T> that)
-
-
Method Detail
-
process
@Nonnull public T process(@Nullable S source)
Processes a source object and returns a target object.- Parameters:
source- A source object.- Returns:
- A target object processed by one of the registered
JdbiInterceptorinstances.
-
addFirst
public void addFirst(JdbiInterceptor<S,T> interceptor)
Registers a new interceptor at the beginning of the chain. Any subsequent call toprocess(Object)will use this interceptor before all other already registered interceptors.- Parameters:
interceptor- An object implementingJdbiInterceptor.
-
addLast
public void addLast(JdbiInterceptor<S,T> interceptor)
Registers a new interceptor at the end of the chain. Any subsequent call toprocess(Object)will use this interceptor after all other already registered interceptors.- Parameters:
interceptor- An object implementingJdbiInterceptor.
-
-