Skip to content

LunarWatcher/KClassUnpacker

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Setup

If you haven't already, link Jitpack:

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

Add the processor:

apply plugin: 'kotlin-kapt'
...

dependencies {
    kapt 'com.github.LunarWatcher:KClassUnpacker:$version'
    compileOnly "com.github.LunarWatcher:KClassUnpacker:$version"
}

Where $version is either a variable, or the version you want to use in plain text (in which case, replace it with the version you want). The available versions can be seen in the releases

Usage

Annotate a data class with @AutoUnpack. After that, you can write code like:

for(field in someDataClass) {
    do something with the fields
}

Motivation

This post on SO.

License

Because the code is posted on SO as well, the license is CC-BY-SA 3.0 here too (the same as the SO post is licensed under), to avoid licensing conflicts between the repo and the post. So whether you copy the code or use the dependency, the licenses are identical.