hotchemi / tiamat

Reactive SharedPreferences code generator for Android.
https://hotchemi.github.io/tiamat
Apache License 2.0
69 stars 4 forks source link

Automatic preference/key name generation from class/field name #11

Open yshrsmz opened 7 years ago

yshrsmz commented 7 years ago

Currently we need to manually define SharedPreferences name and key name, but what if we can generate these name from class/field name?

for example

@Pref
class Sample {  // preference name will be "sample"
    @Key
    long longValue = false;  // key name will be "long_value"
    @Key
    String stringValue = "default_value";  // key name will be "string_value"
}

logic is quite simple, just convert CamelCase to snake_case. Of course we can still provide custom name with @Key(name = "key_name")

hotchemi commented 7 years ago

Interesting, I'm for it!

yshrsmz commented 7 years ago

thanks, will do this asap! (sorry I didn't notice that #4 is about this)

hotchemi commented 7 years ago

NP! @yshrsmz Ah, actually rxjava2 branch is the latest, so can you reference the branch rather than master?