Class RandomService

java.lang.Object
net.datafaker.service.RandomService

public class RandomService extends Object
  • Constructor Details

    • RandomService

      public RandomService()
      Uses a default shared random.
    • RandomService

      public RandomService(Random random)
      Parameters:
      random - If null is passed in, a default Random is assigned
  • Method Details

    • nextInt

      public int nextInt()
    • nextInt

      public int nextInt(int maxExclusive)
    • nextInt

      public Integer nextInt(int minInclusive, int maxInclusive)
    • nextInt

      public int nextInt(Range<Integer> range)
    • nextFloat

      public float nextFloat()
    • nextLong

      public long nextLong()
    • nextLong

      public long nextLong(long maxExclusive)
    • nextLong

      public long nextLong(Range<Long> range)
    • nextLong

      public long nextLong(long min, long max)
      A random long value within given range. If min == max then method always returns min. Otherwise, max is exclusive.
      Parameters:
      min - lower bound (inclusive)
      max - upper bound (exclusive in most cases)
      Returns:
      a random long value between min and max
    • nextDouble

      public double nextDouble()
    • nextDouble

      public double nextDouble(double min, double max)
      Parameters:
      min - (inclusive)
      max - (inclusive)
      Returns:
      a random double value between min and max (both inclusive)
    • nextBoolean

      public boolean nextBoolean()
    • nextRandomBytes

      public byte[] nextRandomBytes(int numberOfBytes)
    • hex

      public String hex()
    • hex

      public String hex(int length)
    • hex

      public String hex(int length, boolean upper)
    • getRandomInternal

      public Random getRandomInternal()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object