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