October 2019
Intermediate to advanced
434 pages
11h 54m
English
Let's look at how specifying different use-site targets impacts the generated Java code. We'll start by defining a simple ViewModel class:
class ViewModel( @param:ColorRes val resId:Int )
In this code snippet, we've added a @ColorRes annotation with a use-site of param. By adding this, the ColorRes annotation will be applied to the constructor parameter in the generated Java class:
public final class ViewModel { private final int resId; public final int getResId() { return this.resId; } public ViewModel(@ColorRes int resId) { this.resId = resId; }}
Next, ...
Read now
Unlock full access