Interface DoubleRange


  • public interface DoubleRange
    Range of doubles.
    • Method Detail

      • of

        @NonNull
        static DoubleRange of​(double lower,
                              double upper)
        Creates an immutable DoubleRange.
        Parameters:
        lower - range lower bound
        upper - range upper bound
        Returns:
        a new immutable DoubleRange instance
      • getLower

        double getLower()
        Gets lower bound.
        Returns:
        the lower bound
      • getUpper

        double getUpper()
        Gets upper bound.
        Returns:
        the upper bound
      • contains

        default boolean contains​(double value)
        Tells whether this range may contain some value.
        Parameters:
        value - value to test
        Returns:
        true if the provided value fits within this range, otherwise false
      • clamp

        default double clamp​(double value)
        Clamps a value to this range.
        • In case value is less than lower bound, returns lower bound,
        • otherwise if value is greater than upper bound, returns upper bound,
        • otherwise, returns value.
        Parameters:
        value - value to clamp
        Returns:
        a value clamped to this range
      • scaleFrom

        default double scaleFrom​(double value,
                                 @NonNull
                                 DoubleRange src)
        Scales a value from a given range to this range.

        The given range should respect the following condition: src.getLower() < src.getUpper()

        Parameters:
        value - value to scale
        src - range to scale from
        Returns:
        a value linearly scaled to this range from value in src