nl.vpro.services.MockTransactionService Maven / Gradle / Ivy
package nl.vpro.services;
import java.util.concurrent.Callable;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.meeuw.functional.ThrowAnyRunnable;
public class MockTransactionService implements TransactionService {
@Override
public T executeInNewTransaction(@NonNull Callable callable) throws Exception {
return callable.call();
}
@Override
public T getInNewTransaction(@NonNull Supplier supplier) {
return supplier.get();
}
@Override
public T getInTransaction(@NonNull Supplier supplier) {
return supplier.get();
}
@Override
public void executeInNewTransaction(@NonNull Runnable runnable) {
runnable.run();
}
@Override
public T executeInNewTransaction(S argument, @NonNull Function function) {
return function.apply(argument);
}
@Override
public void executeInNewTransaction(T argument, @NonNull Consumer consumer) {
consumer.accept(argument);
}
@Override
public T executeInReadonlyTransaction(@NonNull Callable callable) throws Exception {
readonly();
return callable.call();
}
@Override
public T getInReadonlyTransaction(@NonNull Supplier supplier) {
readonly();
return supplier.get();
}
@Override
public void executeInReadonlyTransaction(@NonNull ThrowAnyRunnable runnable) {
readonly();
runnable.run();
}
@Override
public void executeInReadonlyTransaction(@NonNull Runnable runnable) {
readonly();
runnable.run();
}
@Override
public T executeInReadonlyTransaction(S argument, @NonNull Function function) {
readonly();
return function.apply(argument);
}
@Override
public void executeInReadonlyTransaction(T argument, @NonNull Consumer consumer) {
readonly();
consumer.accept(argument);
}
protected void readonly() {
}
}