randomNumber() — netty Function Reference
Architecture documentation for the randomNumber() function in WebSocketUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD fbf9a1d0_ab6c_836e_a9ba_fb90ac52ecd6["randomNumber()"] 32ad3c78_b425_e854_d489_6f60f2c146e2["WebSocketUtil"] fbf9a1d0_ab6c_836e_a9ba_fb90ac52ecd6 -->|defined in| 32ad3c78_b425_e854_d489_6f60f2c146e2 style fbf9a1d0_ab6c_836e_a9ba_fb90ac52ecd6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketUtil.java lines 117–141
static int randomNumber(int minimum, int maximum) {
assert minimum < maximum;
double fraction = ThreadLocalRandom.current().nextDouble();
// the idea here is that nextDouble gives us a random value
//
// 0 <= fraction <= 1
//
// the distance from min to max declared as
//
// dist = max - min
//
// satisfies the following
//
// min + dist = max
//
// taking into account
//
// 0 <= fraction * dist <= dist
//
// we've got
//
// min <= min + fraction * dist <= max
return (int) (minimum + fraction * (maximum - minimum));
}
Domain
Subdomains
Source
Frequently Asked Questions
What does randomNumber() do?
randomNumber() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketUtil.java.
Where is randomNumber() defined?
randomNumber() is defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketUtil.java at line 117.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free