nl.vpro.services.WithUserTransactionServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of user-domain Show documentation
Show all versions of user-domain Show documentation
Domain classes and interfaces related to accountability, users and organizations.
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 nl.vpro.domain.user.Trusted;
/**
* This is a {@link TransactionService} that will do everything on behalf of one specified user, using
* a {@link DoAsTransactionService}.
*
* @author Michiel Meeuwissen
* @since 5.7
*/
public class WithUserTransactionServiceImpl implements TransactionService {
private final DoAsTransactionService doAsTransactionService;
private final Trusted user;
public WithUserTransactionServiceImpl(@NonNull Trusted user, @NonNull DoAsTransactionService doAsTransactionService) {
this.doAsTransactionService = doAsTransactionService;
this.user = user;
}
@Override
public T executeInNewTransaction(@NonNull Callable callable) {
return doAsTransactionService.executeInNewTransaction(user, callable);
}
@Override
public T executeInTransaction(@NonNull Callable callable) {
return doAsTransactionService.executeInTransaction(user, callable);
}
@Override
public T getInNewTransaction(@NonNull Supplier supplier) {
return doAsTransactionService.getInNewTransaction(user, supplier);
}
@Override
public T getInTransaction(@NonNull Supplier supplier) {
return doAsTransactionService.getInTransaction(user, supplier);
}
@Override
public void executeInNewTransaction(@NonNull Runnable runnable) {
doAsTransactionService.executeInNewTransaction(user, runnable);
}
@Override
public void executeInTransaction(@NonNull Runnable runnable) {
doAsTransactionService.executeInTransaction(user, runnable);
}
@Override
public T executeInNewTransaction(S argument, @NonNull Function function) {
return doAsTransactionService.executeInNewTransaction(user, argument, function);
}
@Override
public void executeInNewTransaction(T argument, @NonNull Consumer consumer) {
doAsTransactionService.executeInNewTransaction(user, argument, consumer);
}
@Override
public T executeInReadonlyTransaction(@NonNull Callable callable) {
return doAsTransactionService.executeInReadonlyTransaction(user, callable);
}
@Override
public T getInReadonlyTransaction(@NonNull Supplier supplier) {
return doAsTransactionService.getInReadonlyTransaction(user, supplier);
}
@Override
public void executeInReadonlyTransaction(@NonNull Runnable runnable) {
doAsTransactionService.executeInReadonlyTransaction(user, runnable);
}
@Override
public T executeInReadonlyTransaction(S argument, @NonNull Function function) {
return doAsTransactionService.executeInReadonlyTransaction(user, argument, function);
}
@Override
public void executeInReadonlyTransaction(T argument, @NonNull Consumer consumer) {
doAsTransactionService.executeInReadonlyTransaction(user, argument, consumer);
}
@Override
public String toString() {
return user + "->" + doAsTransactionService;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy