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

io.quarkus.redis.runtime.datasource.TransactionResultImpl 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.Collections;
import java.util.Iterator;
import java.util.List;

import io.quarkus.redis.datasource.transactions.TransactionResult;

public class TransactionResultImpl implements TransactionResult {

    public static final TransactionResult DISCARDED = new TransactionResultImpl(true, Collections.emptyList());

    private final List results = new ArrayList<>();
    private final boolean discarded;

    public TransactionResultImpl(boolean discarded, List res) {
        this.results.addAll(res);
        this.discarded = discarded;
    }

    @Override
    public boolean discarded() {
        return discarded;
    }

    @Override
    public int size() {
        return results.size();
    }

    @Override
    public boolean isEmpty() {
        return results.isEmpty();
    }

    @SuppressWarnings("unchecked")
    @Override
    public  T get(int index) {
        return (T) results.get(index);
    }

    @Override
    public Iterator iterator() {
        return results.iterator();
    }
}