Package org.apache.sshd.common.random
Class SingletonRandomFactory
- java.lang.Object
-
- org.apache.sshd.common.random.AbstractRandom
-
- org.apache.sshd.common.random.SingletonRandomFactory
-
- All Implemented Interfaces:
java.util.function.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 Summary
Fields Modifier and Type Field Description private NamedFactory<Random>
factory
private Random
random
-
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
Fields inherited from interface org.apache.sshd.common.OptionalFeature
FALSE, TRUE
-
-
Constructor Summary
Constructors Constructor Description SingletonRandomFactory(NamedFactory<Random> factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Random
create()
void
fill(byte[] bytes, int start, int len)
Fill part of bytes with random values.java.lang.String
getName()
boolean
isSupported()
int
random(int max)
Returns a pseudo-random uniformly distributedint
in the half-open range [0, n).-
Methods inherited from class org.apache.sshd.common.random.AbstractRandom
toString
-
-
-
-
Field Detail
-
factory
private final NamedFactory<Random> factory
-
random
private final Random random
-
-
Constructor Detail
-
SingletonRandomFactory
public SingletonRandomFactory(NamedFactory<Random> factory)
-
-
Method Detail
-
isSupported
public boolean isSupported()
- Specified by:
isSupported
in interfaceOptionalFeature
-
fill
public void fill(byte[] bytes, int start, int len)
Description copied from interface:Random
Fill part of bytes with random values.
-
random
public int random(int max)
Description copied from interface:Random
Returns a pseudo-random uniformly distributedint
in the half-open range [0, n).
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceNamedResource
- Returns:
- The resource name
-
-