All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.redis.runtime.datasource.TransactionHolder Maven / Gradle / Ivy

There is a newer version: 3.17.5
Show newest version
package io.quarkus.redis.runtime.datasource;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

import io.vertx.mutiny.redis.client.Response;

public class TransactionHolder {

    private List> mappers = new ArrayList<>();
    private volatile boolean discarded = false;

    public void enqueue(Function mapper) {
        mappers.add(mapper);
    }

    public List map(Response response) {
        List results = new ArrayList<>();
        for (int i = 0; i < mappers.size(); i++) {
            results.add(mappers.get(i).apply(response.get(i)));
        }
        return results;
    }

    public void discard() {
        discarded = true;
    }

    public boolean discarded() {
        return discarded;
    }
}