File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed
spring-core/src/main/java/org/springframework/util Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
20
20
import java .util .concurrent .atomic .AtomicLong ;
21
21
22
22
/**
23
- * A simple {@link IdGenerator} that starts at 1 and increments by 1 with each call.
23
+ * A simple {@link IdGenerator} that starts at 1, increments up to
24
+ * {@link Long#MAX_VALUE}, and then rolls over.
24
25
*
25
26
* @author Rossen Stoyanchev
26
27
* @since 4.1.5
27
28
*/
28
29
public class SimpleIdGenerator implements IdGenerator {
29
30
30
- private final AtomicLong mostSigBits = new AtomicLong (0 );
31
-
32
31
private final AtomicLong leastSigBits = new AtomicLong (0 );
33
32
34
33
35
34
@ Override
36
35
public UUID generateId () {
37
- long leastSigBits = this .leastSigBits .incrementAndGet ();
38
- if (leastSigBits == 0 ) {
39
- this .mostSigBits .incrementAndGet ();
40
- }
41
- return new UUID (this .mostSigBits .get (), leastSigBits );
36
+ return new UUID (0 , this .leastSigBits .incrementAndGet ());
42
37
}
43
38
44
39
}
You can’t perform that action at this time.
0 commit comments