use of io.smallrye.context.SmallRyeThreadContext in project smallrye-mutiny by smallrye.
the class BaseContextPropagationInterceptor method decorate.
@Override
public <T> BinaryOperator<T> decorate(BinaryOperator<T> operator) {
SmallRyeThreadContext context = getThreadContext();
if (context.isContextualized(operator) || context.isEmpty()) {
return operator;
}
BiFunction<T, T, T> function = context.contextualFunction(operator);
return new ContextualizedBinaryOperator<>(function);
}
use of io.smallrye.context.SmallRyeThreadContext in project smallrye-mutiny by smallrye.
the class BaseContextPropagationInterceptor method decorate.
@Override
public BooleanSupplier decorate(BooleanSupplier supplier) {
SmallRyeThreadContext context = getThreadContext();
if (context.isContextualized(supplier) || context.isEmpty()) {
return supplier;
}
Supplier<Boolean> contextualized = context.contextualSupplier(supplier::getAsBoolean);
return new ContextualizedBooleanSupplier(contextualized);
}
use of io.smallrye.context.SmallRyeThreadContext in project smallrye-mutiny by smallrye.
the class BaseContextPropagationInterceptor method decorate.
@SuppressWarnings("unchecked")
@Override
public <I1, I2, I3, I4, I5, I6, I7, O> Functions.Function7<I1, I2, I3, I4, I5, I6, I7, O> decorate(Functions.Function7<I1, I2, I3, I4, I5, I6, I7, O> function) {
SmallRyeThreadContext context = getThreadContext();
if (context.isContextualized(function) || context.isEmpty()) {
return function;
}
Function<Object[], O> fun = context.contextualFunction(args -> function.apply((I1) args[0], (I2) args[1], (I3) args[2], (I4) args[3], (I5) args[4], (I6) args[5], (I7) args[6]));
return new ContextualizedFunction7<>(fun);
}
use of io.smallrye.context.SmallRyeThreadContext in project smallrye-mutiny by smallrye.
the class BaseContextPropagationInterceptor method decorate.
@Override
public LongConsumer decorate(LongConsumer consumer) {
SmallRyeThreadContext context = getThreadContext();
if (context.isContextualized(consumer) || context.isEmpty()) {
return consumer;
}
Consumer<Long> cons = context.contextualConsumer(consumer::accept);
return new ContextualizedLongConsumer(cons);
}
use of io.smallrye.context.SmallRyeThreadContext in project smallrye-mutiny by smallrye.
the class BaseContextPropagationInterceptor method decorate.
@SuppressWarnings("unchecked")
@Override
public <I1, I2, I3, O> Functions.Function3<I1, I2, I3, O> decorate(Functions.Function3<I1, I2, I3, O> function) {
SmallRyeThreadContext context = getThreadContext();
if (context.isContextualized(function) || context.isEmpty()) {
return function;
}
Function<Object[], O> fun = context.contextualFunction(args -> function.apply((I1) args[0], (I2) args[1], (I3) args[2]));
return new ContextualizedFunction3<>(fun);
}
Aggregations