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

com.alibaba.middleware.ushura.poller.GenericPoller Maven / Gradle / Ivy

There is a newer version: 2.0.20
Show newest version
package com.alibaba.middleware.ushura.poller;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author Hanson on 15/12/28.
 */
public class GenericPoller implements Poller{
    private AtomicInteger index = new AtomicInteger(0);
    private List items = new ArrayList();

    public GenericPoller(List items){
        this.items = items;
    }

    public T next() {
        return items.get(Math.abs(index.getAndIncrement() % items.size()));
    }

    public Poller refresh(List items) {
       return new GenericPoller(items);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy