Reference implementation of nanoflakes for Kotlin.
Licensed under the MIT License.
Using in Gradle:
repositories {
maven { url = 'https://maven.cafeteria.dev' }
}
dependencies {
implementation 'com.github.nanoflakes:nanoflakes-kotlin:VERSION'
}
Using in Maven:
<repositories>
<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.nanoflakes</groupId>
<artifactId>nanoflakes-kotlin</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
- The
Ǹanoflakes
class contains utility methods for handling with nanoflakes. - Use
Nanoflakes.localGenerator(epoch, generatorId)
to create a local nanoflake generator.- You can get an epoch by calling
System.currentTimeMillis()
in a Java shell (jjs
,jshell
, etc). - A generator ID must be in the 0-1023 range.
- You can get an epoch by calling
- Use
NanoflakeGenerator.next()
to get a new nanoflake. - The
Nanoflake
class is the result typeNanoflakeGenerator.next()
. It can be used as-is, or getting it's raw or encoded value. It also features utility methods such as getting the creation time of the nanoflake.
Extra support is given on Aru's Discord Server.