Class Doubles

java.lang.Object
net.andreinc.mockneat.abstraction.MockUnitBase
net.andreinc.mockneat.unit.types.Doubles
All Implemented Interfaces:
MockUnit<java.lang.Double>, MockUnitDouble

public class Doubles
extends MockUnitBase
implements MockUnitDouble
  • Constructor Details

  • Method Details

    • doubles

      public static Doubles doubles()

      Returns a Doubles object that can be used to generate arbitrary double values.

      Note: By default the Doubles object returns a random double in the [0.0, 1.0) interval.

      Returns:
      A re-usable Doubles object. The Doubles class implements MockUnitDouble.
    • supplier

      public java.util.function.Supplier<java.lang.Double> supplier()
      Description copied from interface: MockUnit
      This is the sole abstract method of the interface. Needs to be implemented every-time a MockUnit is implemented.
      Specified by:
      supplier in interface MockUnit<java.lang.Double>
      Returns:
      A Supplier<T>.
    • gaussians

      public MockUnitDouble gaussians()

      Returns a new MockUnitDouble that can be used to generate double values (gaussian distribution).

      Returns:
      A new MockUnitDouble
    • range

      public MockUnitDouble range​(double lowerBound, double upperBound)

      Returns a new MockUnitDouble that can be used to generate double values into a given range [lowerBound, upperBound).

      Parameters:
      lowerBound - The lower range.
      upperBound - The upper range.
      Returns:
      A new MockUnitDouble
    • bound

      public MockUnitDouble bound​(double bound)
      Returns a new MockUnitDouble that can be used to generate double values bounded by a specific value [0, bound).
      Parameters:
      bound - The bound value.
      Returns:
      A new MockUnitDouble
    • from

      public MockUnitDouble from​(double[] alphabet)
      Returns a new MockUnitDouble that can be used to generate values from a specific alphabet (array).
      Parameters:
      alphabet - The source of elements.
      Returns:
      A new MockUnitDouble