class RoundRobinLoadBalancer implements LoadBalancer {

    @Override
    public <T> T select(final List<T> elements) {
        if (elements == null) {
            throw new NullPointerException("elements");
        }

        final int size = elements.size();

        if (size == 1) {
            return elements.get(0);
        }

        final int roundRobinIndex = indexUpdater.getAndIncrement(this) & Integer.MAX_VALUE;

        return elements.get(roundRobinIndex % size);
    }

}