@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);
    }
@Test
    public void selectTest() {
        List<Integer> elements = Lists.newArrayList();
        elements.add(0);
        elements.add(1);
        elements.add(2);
        elements.add(3);
        elements.add(4);
        RoundRobinLoadBalancer balancer1 = RoundRobinLoadBalancer.getInstance(1);
        Assert.assertEquals(0, balancer1.select(elements).intValue());
        Assert.assertEquals(1, balancer1.select(elements).intValue());

        RoundRobinLoadBalancer balancer2 = RoundRobinLoadBalancer.getInstance(2);
        Assert.assertEquals(0, balancer2.select(elements).intValue());
        Assert.assertEquals(1, balancer2.select(elements).intValue());
        Assert.assertEquals(2, balancer2.select(elements).intValue());
        Assert.assertEquals(3, balancer2.select(elements).intValue());
        Assert.assertEquals(4, balancer2.select(elements).intValue());
        Assert.assertEquals(0, balancer2.select(elements).intValue());
    }