Skip to content

ShatteredSoftware/datastore

Repository files navigation

datastore

License GitHub Issues Discord Ko-Fi

A safer data structure for generic data in Kotlin.

Usage:

val dataStore = GenericDataStore()
// Simple interface
dataStore.set("test", "Hello, world!")
dataStore.get("test", String::class.java) // "Hello, world!"

// And a shorthand with Kotlin operators
dataStore["test"] = "Hello, world!"
dataStore["number"] = 5
val value: String? = dataStore["test"] // "Hello, world!"
val stringNumber: String? = dataStore["number"] // null
val numberNumber: Int? = dataStore["number"] // 5

// Allows defaults
val valueWithDefault = dataStore.getOrDef("none", "default") // "default"
// And a shorthand syntax
val valueWithDefault = dataStore["none", "default"] // "default"

// And explicit classes, using javaObjectType for primitives and javaClass for classes
val intValue = dataStore.get("number", Int::class.javaObjectType) // 5
val strValue = dataStore.get("test", String::class.javaClass) // "Hello, world!"

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages