Class SingletonRandomFactory

java.lang.Object
org.apache.sshd.common.random.AbstractRandom
org.apache.sshd.common.random.SingletonRandomFactory
All Implemented Interfaces:
Supplier<Random>, BuiltinFactory<Random>, Factory<Random>, NamedFactory<Random>, NamedResource, OptionalFeature, Random, RandomFactory

public class SingletonRandomFactory extends AbstractRandom implements RandomFactory
A random factory wrapper that uses a single random instance. The underlying random instance has to be thread safe.
  • Field Details

  • Constructor Details

  • Method Details

    • isSupported

      public boolean isSupported()
      Specified by:
      isSupported in interface OptionalFeature
    • fill

      public void fill(byte[] bytes, int start, int len)
      Description copied from interface: Random
      Fill part of bytes with random values.
      Specified by:
      fill in interface Random
      Parameters:
      bytes - byte array to be filled.
      start - index to start filling at.
      len - length of segment to fill.
    • random

      public int random(int max)
      Description copied from interface: Random
      Returns a pseudo-random uniformly distributed int in the half-open range [0, n).
      Specified by:
      random in interface Random
      Parameters:
      max - The range upper limit
      Returns:
      The randomly selected value in the range
    • getName

      public String getName()
      Specified by:
      getName in interface NamedResource
      Returns:
      The resource name
    • create

      public Random create()
      Specified by:
      create in interface Factory<Random>
      Returns:
      A new instance