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