ConstantSupplier.java

package org.opentrafficsim.core.distributions;

import java.util.function.Supplier;

/**
 * Supplier implementation for a constant value.
 * <p>
 * Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
 * </p>
 * @author Alexander Verbraeck
 * @author Peter Knoppers
 * @author Wouter Schakel
 * @param <O> type of the object returned by the draw method
 */
public class ConstantSupplier<O> implements Supplier<O>
{

    /** Value. */
    private final O value;

    /**
     * Constructor.
     * @param value value
     */
    public ConstantSupplier(final O value)
    {
        this.value = value;
    }

    @Override
    public O get()
    {
        return this.value;
    }

    /**
     * Returns the value.
     * @return value
     */
    public O getValue()
    {
        return this.value;
    }

    @Override
    public String toString()
    {
        return "ConstantSupplier [value=" + this.value + "]";
    }

}