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

com.playtika.shepherd.inernal.CheckedHerd Maven / Gradle / Ivy

package com.playtika.shepherd.inernal;

public class CheckedHerd implements Herd {

    private final Herd herd;
    private boolean requested = false;

    public static Herd checked(Herd herd){
        return new CheckedHerd(herd);
    }

    private CheckedHerd(Herd herd) {
        this.herd = herd;
    }

    @Override
    public Population getPopulation(){
        if(requested){
            throw new IllegalStateException("Should be called only once on rebalance");
        }
        try {
            return herd.getPopulation();
        } finally {
            requested = true;
        }
    }

    @Override
    public void reset() {
        herd.reset();
        requested = false;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy