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

redis.embedded.ports.PredefinedPortProvider Maven / Gradle / Ivy

There is a newer version: 0.11.0
Show newest version
package redis.embedded.ports;

import redis.embedded.PortProvider;
import redis.embedded.exceptions.RedisBuildingException;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by piotrturek on 29/01/15.
 */
public class PredefinedPortProvider implements PortProvider {
    private final List ports = new LinkedList<>();
    private final Iterator current;

    public PredefinedPortProvider(Collection ports) {
        this.ports.addAll(ports);
        this.current = this.ports.iterator();
    }

    @Override
    public synchronized int next() {
        if (!current.hasNext()) {
            throw new RedisBuildingException("Run out of Redis ports!");
        }
        return current.next();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy