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

io.getunleash.strategy.GradualRolloutRandomStrategy Maven / Gradle / Ivy

There is a newer version: 9.2.4
Show newest version
package io.getunleash.strategy;

import java.util.Map;
import java.util.Random;

public final class GradualRolloutRandomStrategy implements Strategy {
    protected static final String PERCENTAGE = "percentage";
    private static final String STRATEGY_NAME = "gradualRolloutRandom";

    private final Random random;

    public GradualRolloutRandomStrategy() {
        random = new Random();
    }

    protected GradualRolloutRandomStrategy(long seed) {
        random = new Random(seed);
    }

    @Override
    public String getName() {
        return STRATEGY_NAME;
    }

    @Override
    public boolean isEnabled(final Map parameters) {
        int percentage = StrategyUtils.getPercentage(parameters.get(PERCENTAGE));
        int randomNumber = random.nextInt(100) + 1;
        return percentage >= randomNumber;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy