Skip to content

nanoflakes/nanoflakes-kotlin

Repository files navigation

Nanoflakes - Kotlin

Maven metadata URL GitHub issues License Twitter

Reference implementation of nanoflakes for Kotlin.

Licensed under the MIT License.

Installation

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>

Usage

  • 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.
  • Use NanoflakeGenerator.next() to get a new nanoflake.
  • The Nanoflake class is the result type NanoflakeGenerator.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.

Support

Extra support is given on Aru's Discord Server.

Aru's Discord Server

Releases

No releases published

Packages

No packages published

Languages