Skip to content

Commit 41f8ed7

Browse files
authored
Rename variants to versions in documentation and code (#68)
1 parent 80512a1 commit 41f8ed7

File tree

14 files changed

+37
-37
lines changed

14 files changed

+37
-37
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ The original use case for JUG was generation of UUID values. This is done by fir
6161
For example:
6262

6363
```java
64-
UUID uuid = Generators.timeBasedGenerator().generate(); // Variant 1
65-
UUID uuid = Generators.randomBasedGenerator().generate(); // Variant 4
66-
UUID uuid = Generators.nameBasedgenerator().generate("string to hash"); // Variant 5
67-
// With JUG 4.1+: support for https://github.com/uuid6/uuid6-ietf-draft variants 6 and 7:
68-
UUID uuid = Generators.timeBasedReorderedGenerator().generate(); // Variant 6
69-
UUID uuid = Generators.timeBasedEpochGenerator().generate(); // Variant 7
64+
UUID uuid = Generators.timeBasedGenerator().generate(); // Version 1
65+
UUID uuid = Generators.randomBasedGenerator().generate(); // Version 4
66+
UUID uuid = Generators.nameBasedgenerator().generate("string to hash"); // Version 5
67+
// With JUG 4.1+: support for https://github.com/uuid6/uuid6-ietf-draft versions 6 and 7:
68+
UUID uuid = Generators.timeBasedReorderedGenerator().generate(); // Version 6
69+
UUID uuid = Generators.timeBasedEpochGenerator().generate(); // Version 7
7070
```
7171

7272
If you want customize generators, you may also just want to hold on to generator instance:
@@ -137,7 +137,7 @@ and get full instructions, but to generate 5 Random-based UUIDs, you would use:
137137

138138
java -jar target/java-uuid-generator-4.1.1-SNAPSHOT.jar -c 5 r
139139

140-
(where `-c` (or `--count`) means number of UUIDs to generate, and `r` means Random-based variant)
140+
(where `-c` (or `--count`) means number of UUIDs to generate, and `r` means Random-based version)
141141

142142
NOTE: this functionality is included as of JUG 4.1 -- with earlier versions you would need a bit longer invocation as Jar metadata did not specify "Main-Class".
143143
If so, you would need to use

release-notes/FAQ

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Name-based: 1 million/second (depends on length, namespace etc; this with MD5)
5555

5656
So with default settings, time-based algorithm is by far the fastest;
5757
usually followed by name/hash based alternative (for short/medium
58-
names at least), and random-based variant being slowest.
58+
names at least), and random-based version being slowest.
5959

6060
Finally, if performance _really_ is very important for you, there
6161
is a further complication when using time-based algorithm; Java's
@@ -95,7 +95,7 @@ native uuidgen), using random-based method may be the best option;
9595
although there is a file-locking base synchronizer available for
9696
time-based generation. This works with multiple JVMs, but may not
9797
be applicable to synchronize with non-Java generators.
98-
Random-number based variant should be safe to use, as long as the
98+
Random-number based version should be safe to use, as long as the
9999
underlying random number generator is good (which SecureRandom by
100100
JDK should be).
101101

release-notes/USAGE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ the way a new JVM is usually instantiated between calls:
4949

5050
* Generating the first UUID can be remarkably slow. This is because
5151
a new secure random number generator is initialized at that time (if
52-
using random number based variant)
52+
using random number based version)
5353
Subsequent calls are faster, but this has to be done using --count
5454
command-line argument, to create multiple UUIDs with same invocation.
5555
* Generating time-based UUIDs is not as secure due to JVM being re-initialized

src/main/java/com/fasterxml/uuid/Generators.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public static NameBasedGenerator nameBasedGenerator(UUID namespace, MessageDiges
119119

120120
/**
121121
* Factory method for constructing UUID generator that generates UUID using
122-
* variant 7 (Unix Epoch time+random based).
122+
* version 7 (Unix Epoch time+random based).
123123
*/
124124
public static TimeBasedEpochGenerator timeBasedEpochGenerator()
125125
{
@@ -128,7 +128,7 @@ public static TimeBasedEpochGenerator timeBasedEpochGenerator()
128128

129129
/**
130130
* Factory method for constructing UUID generator that generates UUID using
131-
* variant 7 (time+random based), using specified Ethernet address
131+
* version 7 (time+random based), using specified Ethernet address
132132
* as the location part of UUID.
133133
* No additional external synchronization is used.
134134
*/
@@ -141,7 +141,7 @@ public static TimeBasedEpochGenerator timeBasedEpochGenerator(Random random)
141141

142142
/**
143143
* Factory method for constructing UUID generator that generates UUID using
144-
* variant 1 (time+location based).
144+
* version 1 (time+location based).
145145
* Since no Ethernet address is passed, a bogus broadcast address will be
146146
* constructed for purpose of UUID generation; usually it is better to
147147
* instead access one of host's NIC addresses using
@@ -155,7 +155,7 @@ public static TimeBasedGenerator timeBasedGenerator()
155155

156156
/**
157157
* Factory method for constructing UUID generator that generates UUID using
158-
* variant 1 (time+location based), using specified Ethernet address
158+
* version 1 (time+location based), using specified Ethernet address
159159
* as the location part of UUID.
160160
* No additional external synchronization is used.
161161
*/
@@ -166,7 +166,7 @@ public static TimeBasedGenerator timeBasedGenerator(EthernetAddress ethernetAddr
166166

167167
/**
168168
* Factory method for constructing UUID generator that generates UUID using
169-
* variant 1 (time+location based), using specified Ethernet address
169+
* version 1 (time+location based), using specified Ethernet address
170170
* as the location part of UUID, and specified synchronizer (which may add
171171
* additional restrictions to guarantee system-wide uniqueness).
172172
*
@@ -189,7 +189,7 @@ public static TimeBasedGenerator timeBasedGenerator(EthernetAddress ethernetAddr
189189

190190
/**
191191
* Factory method for constructing UUID generator that generates UUID using
192-
* variant 1 (time+location based), using specified Ethernet address
192+
* version 1 (time+location based), using specified Ethernet address
193193
* as the location part of UUID, and specified {@link UUIDTimer} instance
194194
* (which includes embedded synchronizer that defines synchronization behavior).
195195
*/
@@ -206,7 +206,7 @@ public static TimeBasedGenerator timeBasedGenerator(EthernetAddress ethernetAddr
206206

207207
/**
208208
* Factory method for constructing UUID generator that generates UUID using
209-
* variant 6 (time+location based, reordered for DB locality). Since no Ethernet
209+
* version 6 (time+location based, reordered for DB locality). Since no Ethernet
210210
* address is passed, a bogus broadcast address will be constructed for purpose
211211
* of UUID generation; usually it is better to instead access one of host's NIC
212212
* addresses using {@link EthernetAddress#fromInterface} which will use one of
@@ -219,7 +219,7 @@ public static TimeBasedReorderedGenerator timeBasedReorderedGenerator()
219219

220220
/**
221221
* Factory method for constructing UUID generator that generates UUID using
222-
* variant 6 (time+location based, reordered for DB locality), using specified
222+
* version 6 (time+location based, reordered for DB locality), using specified
223223
* Ethernet address as the location part of UUID. No additional external
224224
* synchronization is used.
225225
*/
@@ -230,7 +230,7 @@ public static TimeBasedReorderedGenerator timeBasedReorderedGenerator(EthernetAd
230230

231231
/**
232232
* Factory method for constructing UUID generator that generates UUID using
233-
* variant 6 (time+location based, reordered for DB locality), using specified
233+
* version 6 (time+location based, reordered for DB locality), using specified
234234
* Ethernet address as the location part of UUID, and specified
235235
* {@link UUIDTimer} instance (which includes embedded synchronizer that defines
236236
* synchronization behavior).

src/main/java/com/fasterxml/uuid/Jug.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public class Jug
3131
TYPES.put("time-based", "t");
3232
TYPES.put("random-based", "r");
3333
TYPES.put("name-based", "n");
34-
TYPES.put("reordered-time-based", "o"); // Variant 6
35-
TYPES.put("epoch-time-based", "e"); // Variant 7
34+
TYPES.put("reordered-time-based", "o"); // Version 6
35+
TYPES.put("epoch-time-based", "e"); // Version 7
3636
}
3737

3838
protected final static HashMap<String,String> OPTIONS = new HashMap<String,String>();
@@ -227,7 +227,7 @@ public static void main(String[] args)
227227

228228
switch (typeC) {
229229
case 't': // time-based
230-
case 'o': // reordered-time-based (Variant 6)
230+
case 'o': // reordered-time-based (Version 6)
231231
// 30-Jun-2022, tatu: Is this true? My former self must have had his
232232
// reasons so leaving as is but... odd.
233233
usesRnd = true;

src/main/java/com/fasterxml/uuid/NoArgGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/**
66
* Intermediate base class for UUID generators that do not take arguments for individual
7-
* calls. This includes random and time-based variants, but not name-based ones.
7+
* calls. This includes random and time-based versions, but not name-based ones.
88
*
99
* @since 3.0
1010
*/

src/main/java/com/fasterxml/uuid/UUIDComparator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
/**
77
* Default {@link java.util.UUID} comparator is not very useful, since
88
* it just does blind byte-by-byte comparison which does not work well
9-
* for time+location - based UUIDs. Additionally it also uses signed
9+
* for time+location - based UUIDs. Additionally, it also uses signed
1010
* comparisons for longs which can lead to unexpected behavior
1111
* This comparator does implement proper lexical ordering: starting with
1212
* type (different types are collated
1313
* separately), followed by time and location (for time/location based),
1414
* and simple lexical (byte-by-byte) ordering for name/hash and random
15-
* variants.
15+
* versions.
1616
*
1717
* @author tatu
1818
*/
@@ -36,7 +36,7 @@ public static int staticCompare(UUID u1, UUID u2)
3636
if (diff != 0) {
3737
return diff;
3838
}
39-
// Second: for time-based variant, order by time stamp:
39+
// Second: for time-based version, order by time stamp:
4040
if (type == UUIDType.TIME_BASED.raw()) {
4141
diff = compareULongs(u1.timestamp(), u2.timestamp());
4242
if (diff == 0) {

src/main/java/com/fasterxml/uuid/UUIDGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected UUIDGenerator() { }
4242
*/
4343

4444
/**
45-
* Accessor for determining type of UUIDs (variant) that this
45+
* Accessor for determining type of UUIDs (version) that this
4646
* generator instance will produce.
4747
*/
4848
public abstract UUIDType getType();

src/main/java/com/fasterxml/uuid/impl/NameBasedGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/**
1111
* Implementation of UUID generator that uses one of name-based generation methods
12-
* (variants 3 (MD5) and 5 (SHA1)).
12+
* (versions 3 (MD5) and 5 (SHA1)).
1313
*<p>
1414
* As all JUG provided implementations, this generator is fully thread-safe; access
1515
* to digester is synchronized as necessary.

src/main/java/com/fasterxml/uuid/impl/TimeBasedEpochGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Implementation of UUID generator that uses time/location based generation
1212
* method field from the Unix Epoch timestamp source - the number of
1313
* milliseconds seconds since midnight 1 Jan 1970 UTC, leap seconds excluded.
14-
* This is usually referred to as "Variant 7".
14+
* This is usually referred to as "Version 7".
1515
* <p>
1616
* As all JUG provided implementations, this generator is fully thread-safe.
1717
* Additionally it can also be made externally synchronized with other instances

0 commit comments

Comments
 (0)