001package io.prometheus.metrics.model.snapshots;
002
003/**
004 * Immutable representation of a Quantile.
005 */
006public class Quantile {
007
008    private final double quantile;
009    private final double value;
010
011    /**
012     * @param quantile expecting 0.0 <= quantile <= 1.0, otherwise an {@link IllegalArgumentException} will be thrown.
013     * @param value
014     */
015    public Quantile(double quantile, double value) {
016        this.quantile = quantile;
017        this.value = value;
018        validate();
019    }
020
021    public double getQuantile() {
022        return quantile;
023    }
024
025    public double getValue() {
026        return value;
027    }
028
029    private void validate() {
030        if (quantile < 0.0 || quantile > 1.0) {
031            throw new IllegalArgumentException(quantile + ": Illegal quantile. Expecting 0 <= quantile <= 1");
032        }
033    }
034}