/PersistableGenerator

A tool for generating Persistable wrapper implementation.

Primary LanguageJavaApache License 2.0Apache-2.0

PersistableGenerator

Download

codebeat badge

A tool for generating Persistable implementation.

Created specially for Binaryprefs

PersistableGenerator generates the Persistable wrapper for data classes to get rid of boilerplate source code.

All you need is to annotate the data class by the annotation @PersistableGenerator

Sample

Java

@PersistableGenerator public class SomeModel {
  int age;
  private String name;

  public SomeModel() {
  }

  public SomeModel(int age, String name) {
    this.age = age;
    this.name = name;
  }

  public String getName() {
    return name;
  }

  public int getAge() {
    return age;
  }
}

Kotlin

@PersistableGenerator
data class SomeModel(val name: String, val age: Int, val someList: List<OtherModel>, val someInts: List<Int>, val someStrings: List<String>)

Library generates wrapper class SomeModelPersistable implements Persistable and you can use it next way:

 Persistable persistableModel = new SomeModelPersistable(model);

Integration

def persistableGeneratorVersion = 'x.x.x'
...
dependencies {
  provided "com.github.lliepmah:persistable-generator-annotations:$persistableGeneratorVersion"
  annotationProcessor "com.github.lliepmah:persistable-generator-compiler:$persistableGeneratorVersion"
  ...
}

Kotlin

def persistableGeneratorVersion = 'x.x.x'

dependencies {
  provided "com.github.lliepmah:persistable-generator-annotations:$persistableGeneratorVersion"
  kapt "com.github.lliepmah:persistable-generator-compiler:$persistableGeneratorVersion"
  ...
}

ProGuard

No special ProGuard rules required.