Skip to content

Commit

Permalink
Fix #73: add Generators.defaultTimeBasedGenerator() (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgalbraith authored May 14, 2023
1 parent 7c7c4a0 commit 1037107
Show file tree
Hide file tree
Showing 8 changed files with 686 additions and 72 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ UUID uuid = gen.generate();
UUID anotherUuid = gen.generate();
```

If your machine has a standard IP networking setup, the `Generators.defaultTimeBasedGenerator` (added in JUG 4.2)
factory method will try to determine which network interface corresponds to the default route for
all outgoing network traffic, and use that for creating a time based generator.
This is likely a good choice for common usage scenarios if you want a version 1 UUID generator.

```java
TimeBasedGenerator gen = Generators.defaultTimeBasedGenerator();
UUID uuid = gen.generate();
UUID anotherUuid = gen.generate();
```

Generators are fully thread-safe, so a single instance may be shared among multiple threads.

Javadocs for further information can be found from [Project Wiki](../../wiki).
Expand Down
4 changes: 4 additions & 0 deletions release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,7 @@ Hal Hildebrand (Hellblazer@github)
Dirk-Jan Rutten (excitement-engineer@github)
* Reported #69: UUID version 7 implementation sorting incorrect?
[4.1.1]

Paul Galbraith (pgalbraith@github)
* Contributed #52: Add `Generators.egressTimeBasedGenerator()` method that constructs
`TimedBasedGenerator` with a sensible choice of interface
Loading

0 comments on commit 1037107

Please sign in to comment.