Commit Graph

44 Commits

Author SHA1 Message Date
Fabio Lima f80eb4029c Add support for RandomGenerator in Java 17 #19 2022-07-09 14:43:36 -03:00
Fabio Lima 28ece966b4 handle clock drift #18 2022-04-21 21:34:33 -03:00
Fabio Lima 745bd55ffc feat: handle clock drift #18
Added drift tolerance of 10 seconds to preserve monotonicity when the
system clock is adjusted by NTP after a small clock drift or when the
system clock jumps back by 1 second due to leap second.

The random component is incremented when the current time:
- is the same as the previous time;
- has moved backwards up to 10 seconds.

The time component is also incremented if the random component is
exceeded, which is quite rare.
2022-04-21 14:53:06 -03:00
Fabio Lima 236044af02
Update README.md 2022-03-01 11:16:09 -03:00
Fabio Lima 44bab60674
Update README.md 2021-11-28 23:34:53 -03:00
Fabio Lima bf3b93167b
Update README.md 2021-11-28 23:28:06 -03:00
Fabio Lima 5d46bbf2fc
Update README.md 2021-11-28 23:09:48 -03:00
Fabio Lima e30d0bc974
Update README.md 2021-11-27 02:48:08 -03:00
Fabio Lima e03b50f303
Update README.md 2021-11-27 02:45:30 -03:00
Fabio Lima e23370f5fd
Update README.md 2021-11-27 02:44:09 -03:00
Fabio Lima 4b24b03f8f
Update README.md 2021-11-15 08:19:25 -03:00
Fabio Lima 1cc8ed180e
Update README.md 2021-11-15 07:56:11 -03:00
Fabio Lima ced08d1a55 Compare internal fields as unsigned integers #17 2021-11-06 10:06:14 -03:00
Fabio Lima 7b4abe0f9c Merge branch 'master' of https://github.com/f4b6a3/ulid-creator 2021-10-03 23:11:26 -03:00
Fabio Lima 132ab99b77 Provide OSGI support #16
Added OSGi entries to `MANIFEST.MF`:

```
Bundle-ManifestVersion: 2
Bundle-Name: ulid-creator
Bundle-SymbolicName: com.github.f4b6a3.ulid
Bundle-Version: 4.1.0
Export-Package: com.github.f4b6a3.ulid
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
```

The OSGi symbolic name is the same as the root package name:
`com.github.f4b6a3.ulid`
2021-09-04 02:00:57 -03:00
Fabio Lima 27a4f60cb5 Version 4.0.0 #15
Now you call `UlidFactory.newInstance()` and it's variants to get a new
`UlidFactory`.

List of changes:

- Added `UlidFactory.newInstance()`
- Added `UlidFactory.newInstance(Random)`
- Added `UlidFactory.newInstance(Supplier<byte[]>)`
- Added `UlidFactory.newMonotonicInstance()`
- Added `UlidFactory.newMonotonicInstance(Random)`
- Added `UlidFactory.newMonotonicInstance(Supplier<byte[]>)`
- Added benchmark code to compare ULID with UUID
- Removed `DefaultFactory`
- Removed `MonotonicFactory`
- Removed `Ulid.toUpperCase()`
- Removed `RandomGenerator`
2021-08-08 01:35:40 -03:00
Fabio Lima cd849c4e21 Add benchmark code to compare ULID with UUID #14
The benchmark code was created in the direcory `benchmark`.

To execute the benchmark, run the script `./benchmark/run.sh`.

Sorry, there is no `run.bat` file for Windows.
2021-07-25 17:55:29 -03:00
Fabio Lima 0f431d01b1 Add constructors in UlidFactory for random generators #12
New constructors:

- public UlidFactory(Random random) { }
- public UlidFactory(RandomGenerator randomGenerator) { }
2021-07-18 01:21:41 -03:00
Fabio Lima d3277fe372 Module name for Java 9+ #11
Add this line to MANIFEST.MF:

Automatic-Module-Name: com.github.f4b6a3.ulid
2021-07-17 14:02:34 -03:00
Fabio Lima 1dffbf1ebb Add static methods for extracting time and random components #9
Add static methods to Ulid:
 - Ulid.getInstant(String);
 - Ulid.getTime(String);
 - Ulid.getRandom(String);

List of changes:

Updated Ulid
Updated test cases
Updated README.md

Test coverage 99.4%
2021-02-13 20:14:31 -03:00
Fabio Lima 3f10989f74 [maven-release-plugin] prepare for next development iteration 2021-02-04 02:06:28 -03:00
Fabio Lima 4df6fbfa9b Development of version 3.0.0 #7
renamed subpackage 'creator' to 'factory'
2021-01-30 09:29:08 -03:00
Fabio Lima f1eaebd3bd Development of version 3.0.0 #7
continuing...

List of changes:

Improve Ulid
Create UlidFactory
Create DefaultUlidFactory
Create MonotonicUlidFactory
Improve UlidTest
Create UlidFactoryTest
Create DefaultUlidFactoryTest
Create MonotonicUlidFactoryTest
Update UniquenessTest
Update README.md
Update javadoc

Test coverage: 99.3%
2021-01-30 07:17:09 -03:00
Fabio Lima e52b2cdefd Add test cases, and remove unused code
List of changes:

Change UlidUtil // remove unused code
Change UlidUtilTest // add tests and remove unused code
Change UlidStructTest // add tests
Change UlidValidator // add methods for char[] args
Optimaze UlidSpecCreator // small optimization
Optimaze UlidStruct // small optimization
Update README.md
2020-11-16 01:39:52 -03:00
Fabio Lima 1bee3ba042 Optimization of the ULID string validation
It's not needed to parse the whole ULID timestamp. All is needed is to
check the first two bits. They are extra bits added by the base-32
encoding. Both bits must be ZERO.
2020-11-09 04:27:20 -03:00
Fabio Lima 75d313c9ed [#6] Move v4 generators to UlidStruct
Moved v4 generators to UlidStruct

List of Changes:

Create UlidStruct.toUuid4()
Create UlidStruct.toString4()
Create UlidCreatorUuidTest // test cases
Create UlidCreatorStringTest // test cases
Add UlidUtil.extractUnixMilliseconds(UUID ulid)
Add UlidUtil.extractUnixMilliseconds(String ulid)
2020-11-08 17:40:50 -03:00
Fabio Lima 73d43dfc41 [#5] Generate ULID compatible with RFC-4122 UUID v4
Now it can generate UUIDs and ULIDs compatible with RFC-4122 UUID v4.

List of Changes:

Created UlidCreator.getUlid4();
Created UlidCreator.getUlidString4();
Updated README.md

Coverage 94.1%
2020-11-08 11:15:22 -03:00
Fabio Lima 54cd5c0595 [#4] Optimize the generation of ULID in string format
Now the generation of ULID in string format is 2.5x faster than before.

List of changes:

Optimize UlidSpecCreator
Optimize UlidConverter
Optimize UlidValidator
Create UlidStruct // class for internal use and test cases
Add test cases
Update README.md
Update javadoc

Coverage 94.3%
2020-11-08 07:55:58 -03:00
Fabio Lima fdd33556a7 [#3] Remove overrun exception
Remove UlidCreatorException // extremely unlikely to occur overrun

Add UlidCreator.toString() // from UUID to crockford base 32

Change DefaultRandomStrategy // no need for thread local SecureRandom

Update test cases
Update README.md
Update javadoc

Test coverage: 94.2%
2020-10-17 21:50:37 -03:00
Fabio Lima 24a2d4ce13 ...
A time out occured while publishing version 2.0.1 to maven central.

The version 2.0.2 will be created to try again.
2020-07-06 23:30:18 -03:00
Fabio Lima 3929965fe9 Fix increment
Fix UlidSpecCreator.increment()
2020-07-06 04:31:17 -03:00
Fábio Lima 1deb79b52e
Update README.md 2020-07-05 00:50:30 -03:00
Fábio Lima d1b8ba9d07
Update README.md 2020-07-05 00:49:48 -03:00
Fabio Lima 327aa7bc6b Version 2.0.0
Rename UlidBasedGuidCreator to UlidSpecCreator

Add method UlidCreator.fromString()
Add RandomStrategy for UlidSpecCreator
Add DefaultRandomStrategy using thread local SecureRandom
Add OtherRandomStrategy for any instance of Random
Add tests cases

Optimize UlidConverter.fromString()
Optimize UlidConverter.toString()
Optimize UlidValidator.isValid()
Optimize UlidSpecCreator

Update README.md
Update tests cases
2020-07-04 12:37:50 -03:00
Fabio Lima 74892d1f7b Updated pom.xml 2020-04-19 20:44:36 -03:00
Fabio Lima c59d1c61f0 Preparing v1.1.0 2020-04-18 02:43:18 -03:00
Fabio Lima ffffe2af51 Updated UlidBasedGuidCreator 2020-03-16 00:34:56 -03:00
Fabio Lima c01a914319 Small optimizations
Optimized methods:
- UlidUtil.fromUuidToUlid()
- UlidUtil.fromUlidToUuid()

Added tests cases:
- UlidUtilTest.testFromUuidToBytes()
- UlidUtilTest.testFromBytesToUuid()
- UlidUtilTest.testToAndFromBytes()

Created classes:
- Benchmarks.java (need to uncomment)
2020-02-25 15:40:35 -03:00
Fabio Lima 1fc0952067 Updated README.md 2020-02-24 04:53:01 -03:00
Fabio Lima 111592751a Remove method from GuidCreator
The method withoutOverrunException() is not necessary anymore.
2020-02-24 00:03:38 -03:00
Fabio Lima 174c76c0a8 Updated README.md 2020-02-23 14:08:30 -03:00
Fabio Lima 8f7aa36960 Updated README.md 2020-02-22 13:22:13 -03:00
Fabio Lima f885a03125 Rearranging the code 2020-02-22 13:07:16 -03:00
Fábio Lima 0ff9125533
Initial commit 2020-02-17 00:29:48 -03:00