1 package org.opentrafficsim.core.distributions;
2
3 import org.djutils.exceptions.Throw;
4
5 /**
6 * Immutable storage for a frequency (or probability) plus a Generator.
7 * @param frequency the (<b>not cumulative</b>) frequency (or probability) of the <cite>generatingObject</cite>
8 * @param object an object
9 * @param <O> Type of the object returned by the draw method
10 */
11 public record FrequencyAndObject<O>(double frequency, O object)
12 {
13 /**
14 * Constructor.
15 * @param frequency the (<b>not cumulative</b>) frequency (or probability) of the <cite>generatingObject</cite>
16 * @param object an object
17 */
18 public FrequencyAndObject
19 {
20 Throw.when(frequency < 0.0, IllegalArgumentException.class, "Negative frequency.");
21 }
22 }