类 RichRandom


  • public class RichRandom
    extends java.lang.Object
    Wrap random for more convenient methods
    • 构造器概要

      构造器 
      构造器 说明
      RichRandom()  
      RichRandom​(java.util.Random random)  
    • 方法概要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      java.lang.String alphanumericString​(int len)
      Generate random string only contains ascii alphabet and number chars([48,58),[65, 91),[97,123) ]) with specific len.
      java.lang.String asciiString​(int len)
      Generate random string only contains ascii printable([20,127)) chars with specific len.
      byte[] bytes​(int len)
      Return a byte array with len, filled by random data.
      static RichRandom currentThreadLocalRandom()
      Return a RichRandom wrap ThreadLocalRandom.
      java.util.stream.DoubleStream doubles()  
      java.util.stream.DoubleStream doubles​(double randomNumberOrigin, double randomNumberBound)  
      java.util.stream.DoubleStream doubles​(long streamSize)  
      java.util.stream.DoubleStream doubles​(long streamSize, double randomNumberOrigin, double randomNumberBound)  
      java.util.Random getRandom()
      Return the delegated random.
      java.util.stream.IntStream ints()  
      java.util.stream.IntStream ints​(int randomNumberOrigin, int randomNumberBound)  
      java.util.stream.IntStream ints​(long streamSize)  
      java.util.stream.IntStream ints​(long streamSize, int randomNumberOrigin, int randomNumberBound)  
      java.util.stream.LongStream longs()  
      java.util.stream.LongStream longs​(long streamSize)  
      java.util.stream.LongStream longs​(long randomNumberOrigin, long randomNumberBound)  
      java.util.stream.LongStream longs​(long streamSize, long randomNumberOrigin, long randomNumberBound)  
      static RichRandom newSecureRandom()
      Return a new RichRandom wrap SecureRandom.
      boolean nextBoolean()  
      void nextBytes​(byte[] bytes)  
      double nextDouble()  
      float nextFloat()  
      double nextGaussian()  
      int nextInt()  
      int nextInt​(int bound)  
      int nextInt​(int begin, int end)
      return a random int value in range [begin, end).
      long nextLong()  
      long nextLong​(long bound)
      Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive).
      long nextLong​(long begin, long end)
      return a random long value in range [begin, end).
      void setSeed​(long seed)  
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • RichRandom

        public RichRandom()
      • RichRandom

        public RichRandom​(java.util.Random random)
    • 方法详细资料

      • newSecureRandom

        public static RichRandom newSecureRandom()
        Return a new RichRandom wrap SecureRandom.
      • currentThreadLocalRandom

        public static RichRandom currentThreadLocalRandom()
        Return a RichRandom wrap ThreadLocalRandom. The returned random is cached by thread.
      • nextInt

        public int nextInt​(int begin,
                           int end)
        return a random int value in range [begin, end).
        参数:
        begin - random int range begin (inclusive)
        end - random int range end (excluded)
      • nextLong

        public long nextLong​(long bound)
        Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive).
        参数:
        bound - the upper bound (exclusive). Must be positive.
        返回:
        the next pseudorandom, uniformly distributed long value between zero (inclusive) and bound (exclusive) from this random number generator's sequence
        抛出:
        java.lang.IllegalArgumentException - if bound is not positive
      • nextLong

        public long nextLong​(long begin,
                             long end)
        return a random long value in range [begin, end).
        参数:
        begin - random long range begin (inclusive)
        end - random long range end (excluded)
      • bytes

        public byte[] bytes​(int len)
        Return a byte array with len, filled by random data.
      • asciiString

        public java.lang.String asciiString​(int len)
        Generate random string only contains ascii printable([20,127)) chars with specific len. The DEL char is excluded.
      • alphanumericString

        public java.lang.String alphanumericString​(int len)
        Generate random string only contains ascii alphabet and number chars([48,58),[65, 91),[97,123) ]) with specific len.
      • nextBytes

        public void nextBytes​(byte[] bytes)
      • nextInt

        public int nextInt()
      • nextInt

        public int nextInt​(int bound)
      • nextLong

        public long nextLong()
      • nextBoolean

        public boolean nextBoolean()
      • nextFloat

        public float nextFloat()
      • nextDouble

        public double nextDouble()
      • setSeed

        public void setSeed​(long seed)
      • nextGaussian

        public double nextGaussian()
      • ints

        public java.util.stream.IntStream ints​(long streamSize)
      • ints

        public java.util.stream.IntStream ints()
      • ints

        public java.util.stream.IntStream ints​(long streamSize,
                                               int randomNumberOrigin,
                                               int randomNumberBound)
      • ints

        public java.util.stream.IntStream ints​(int randomNumberOrigin,
                                               int randomNumberBound)
      • longs

        public java.util.stream.LongStream longs​(long streamSize)
      • longs

        public java.util.stream.LongStream longs()
      • longs

        public java.util.stream.LongStream longs​(long streamSize,
                                                 long randomNumberOrigin,
                                                 long randomNumberBound)
      • longs

        public java.util.stream.LongStream longs​(long randomNumberOrigin,
                                                 long randomNumberBound)
      • doubles

        public java.util.stream.DoubleStream doubles​(long streamSize)
      • doubles

        public java.util.stream.DoubleStream doubles()
      • doubles

        public java.util.stream.DoubleStream doubles​(long streamSize,
                                                     double randomNumberOrigin,
                                                     double randomNumberBound)
      • doubles

        public java.util.stream.DoubleStream doubles​(double randomNumberOrigin,
                                                     double randomNumberBound)
      • getRandom

        public java.util.Random getRandom()
        Return the delegated random.