package net.minecraft.util;

import java.util.Random;

public class IntRange {
    private final int minInclusive;
    private final int maxInclusive;
    
    public IntRange(final int integer1, final int integer2) {
        if (integer2 < integer1) {
            throw new IllegalArgumentException("max must be >= minInclusive! Given minInclusive: " + integer1 + ", Given max: " + integer2);
        }
        this.minInclusive = integer1;
        this.maxInclusive = integer2;
    }
    
    public static IntRange of(final int integer1, final int integer2) {
        return new IntRange(integer1, integer2);
    }
    
    public int randomValue(final Random random) {
        if (this.minInclusive == this.maxInclusive) {
            return this.minInclusive;
        }
        return random.nextInt(this.maxInclusive - this.minInclusive + 1) + this.minInclusive;
    }
    
    public int getMinInclusive() {
        return this.minInclusive;
    }
    
    public int getMaxInclusive() {
        return this.maxInclusive;
    }
    
    @Override
    public String toString() {
        return "IntRange[" + this.minInclusive + "-" + this.maxInclusive + "]";
    }
}
