Skip to content

Kotlin Support

xcesco edited this page Sep 25, 2018 · 4 revisions

Since version 4.1.0, Kripton has an improved support for Kotlin language. If you want to use Kripton Persistence Library with Kotlin, just configure your project gradle config file to work with kapt.

apply plugin: 'com.android.application'
   
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

...

ext {
  kriptonVersion = "5.0.0"
  ...
}

dependencies {
  kapt "com.abubusoft:kripton-processor:${kriptonVersion}"
  implementation "com.abubusoft:kripton-android-library:${kriptonVersion}"
   
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  ...
}

With this configuration, it is possible to use Kripton Annotations in Kotlin source code.

@BindDao(Article::class)
interface DaoArticle : DaoBase<Article> {

  @BindSqlUpdate(where = "id=:id")
  fun update(id: Long, channelId: Long, read: Boolean)

  @BindSqlSelect
  fun selectByChannel(@BindSqlDynamicWhere where: String): LiveData<List<Article>>

  @BindSqlSelect(where = "channelId=:channelId")
  fun selectByChannelUd(channelId: Long): List<Article>

  @BindSqlSelect(where = "channelId=:channelId AND guid=:guid")
  fun selectByGuid(channelId: Long, guid: String): Article
}

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally