All Projects → danysantiago → kotlin-cursor

danysantiago / kotlin-cursor

Licence: Apache-2.0 License
Kotlin Annotation Processor to generate fromCursor and toContentValues of data classes.

Programming Languages

kotlin
9241 projects
shell
77523 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to kotlin-cursor

simple-preferences
Android Library to simplify SharedPreferences use with code generation.
Stars: ✭ 48 (+41.18%)
Mutual labels:  annotation-processor
macOS-cursors-for-Windows
Tested in Windows 10 & 11, 4K, 125%, 150%, 200%. With 2 versions, 2 types and 3 different sizes!
Stars: ✭ 578 (+1600%)
Mutual labels:  cursors
smartstruct
Dart Code Generator for generating mapper classes
Stars: ✭ 20 (-41.18%)
Mutual labels:  annotation-processor
numix-cursor-theme
Numix cursor theme for Linux
Stars: ✭ 52 (+52.94%)
Mutual labels:  cursors
ColdStorage
Lightweight data loading and caching library for android
Stars: ✭ 39 (+14.71%)
Mutual labels:  annotation-processor
Stitch
Simple threading library using annotations for Android
Stars: ✭ 28 (-17.65%)
Mutual labels:  annotation-processor
jvmbuilder
A source code generator for Kotlin data classes to automatically create a Builder class.
Stars: ✭ 16 (-52.94%)
Mutual labels:  annotation-processor
simple-annotation-processor
Simple annotation processor example. Inspired by the idea of "How ButterKnife works?"
Stars: ✭ 54 (+58.82%)
Mutual labels:  annotation-processor
jtsgen
Convert Java Types to TypeScript
Stars: ✭ 34 (+0%)
Mutual labels:  annotation-processor
phinger-cursors
Most likely the most over engineered cursor theme.
Stars: ✭ 332 (+876.47%)
Mutual labels:  cursors
AnnotationProcessing
✔️ㅤ[ARTICLE] Writing your own Annotation Processors in Android
Stars: ✭ 47 (+38.24%)
Mutual labels:  annotation-processor
piri
Piri is a lightweight annotation processing library that generates static factory methods for your Activities and Fragments.
Stars: ✭ 53 (+55.88%)
Mutual labels:  annotation-processor
clickgen
The hassle-free cursor building toolbox
Stars: ✭ 34 (+0%)
Mutual labels:  cursors
BreezeX Cursor
extended KDE cursor
Stars: ✭ 59 (+73.53%)
Mutual labels:  cursors
RapidORM
Quick solutions for Android ORM
Stars: ✭ 24 (-29.41%)
Mutual labels:  annotation-processor
avaje-http
Controller generation for Javalin, Helidon SE.
Stars: ✭ 23 (-32.35%)
Mutual labels:  annotation-processor
generate-kotlin-multiple-rounds
Android sample project demonstrating how to generate Kotlin code through annotation processing, and then feeding it into a second round of annotation processing.
Stars: ✭ 25 (-26.47%)
Mutual labels:  annotation-processor
WinAnalytics
A light-weight android library that can be quickly integrated into any app to use analytics tools.
Stars: ✭ 23 (-32.35%)
Mutual labels:  annotation-processor
dagger2-ktx
Kotlin extension bridge library for Dagger2 (proof-of-concept)
Stars: ✭ 41 (+20.59%)
Mutual labels:  annotation-processor
AutoBindings
Set of annotations that aims to make your Android development experience easier along with lint checks.
Stars: ✭ 15 (-55.88%)
Mutual labels:  annotation-processor

Kotlin-Cursor

An annotation processor that generates extension functions to convert Kotlin data classes to ContentValues and from Cursor.

Usage

Annotate your data class with @KCursorData

@KCursorData
data class Cat(val name: String)

then once the class is processed a file will be generated with the following extension functions:

fun Cat.toContentValues(): ContentValues { /* ... */ }
fun Cursor.toCat(): Cat { /* ... */ }

Custom types

The following types are supported by default:

  • String
  • ByteArray
  • Double
  • Float
  • Int
  • Long
  • Short
  • Boolean

Kotlin-Cursor also supports types that are also annotated with @KCursorData. For exmaple:

@KCursorData
data class Bed(val owner: Cat)

For other types, you need to use the @ColumnAdapter annotation and specify a class that implements ColumnTypeAdapter. For example:

Person.kt

data class Person(
    val name: String,
    @ColumnAdapter(CatListAdapter::class)
    val cats: List<Cat>
)

CatListColumnTypeAdapter.kt:

class CatListAdapter : ColumnTypeAdapter<List<Cat>> {
    override fun fromCursor(cursor: Cursor, columnName: String): List<Cat> {
        val listOfCats = cursor.getString(cursor.getColumnIndexOrThrow("cat_list"))
        return listOfCats.split(',').map { Cat(it) }
    }

    override fun toContentValues(values: ContentValues, columnName: String, value: List<Cat>) {
        values.put("cat_list", value.map { it.name }.joinToString(separator = ","))
    }
}

Setup

Add a Gradle dependency:

compile 'com.github.danysantiago:kotlincursor-api:0.1.1'
kapt 'com.github.danysantiago:kotlincursor-compiler:0.1.1'

Snapshots of the development version are available in Sonatype's snapshots repository.

Thanks

To Gabriel Ittner's auto-value-cursor for which this project is based on.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].