Skip to content
Universally Unique Lexicographically Sortable Identifier ported for Kotlin
Kotlin
Branch: master
Clone or download
Latest commit df55cf2 Nov 24, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper
lib
.gitattributes
.gitignore
CODE_OF_CONDUCT.md
COLLABORATING.md
LICENSE.md
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
kULID.iml restructuring Jul 28, 2019
local.properties
logo.png
settings.gradle

README.md



ulid


KUlid

Unit test coverage

Support me

ULID (Universally Unique Lexicographically Sortable Identifier) generator and parser for Kotlin.

Refer the ULID spec for a more detailed ULID specification.

Installation

Add the JitPack repository to your build.gradle:

allprojects {
   repositories {
      ...
      maven { url 'https://jitpack.io' }
   }
}

Add the dependency to your build.gradle:

dependencies {
    implementation 'com.github.guepardoapps:kulid:1.1.2.0'
}

Usage

ULID generation examples:

val randomUlid = ULID.random()
val generateUlid = ULID.generate(System.currentTimeMillis(), byteArrayOf(0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9))
val stringUlid = ULID.fromString("003JZ9J6G80123456789ABCDEF")

ULID parsing examples:

val ulid = "003JZ9J6G80123456789ABCDEF"
val isValid = ULID.isValid(ulid)        // returns a Boolean indicating if the ULID is valid
val timestamp = ULID.getTimestamp(ulid) // returns a Long
val entropy = ULID.getEntropy(ulid)     // returns a ByteArray

Prior Projects

Requirements

  • Use at least JVM 1.8

Contributors

JonasSchubert
Jonas Schubert

License

KUlid is distributed under the MIT license. See LICENSE for details.

MIT License

Copyright (c) 2019 Jonas Schubert

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You can’t perform that action at this time.