2019-12-02 19:00:00, , American Express Technology
Content Categorization
/Science/Computer Science
/Computers & Electronics/Programming/Java (Programming Language)
Word Count:
2382
Words/Sentence:
36
Reading Time:
23.82 min
Reading Quality:
Advanced
Readability:
16th or higher
The resulting decompiled bytecode shows the difference between these 2:
public final class SetParamAnnTest {
@Nullable
private String myStr;
These target values along with the placement of the annotation are used to pick a default use-site target for an annotation if one is not specified.
If there's more than one applicable target either @param (constructor parameters), @property , or @field are used, in that order.
Let's see an example of this.
@NotNull
public final String getName() {
Lazy var1 = this.name$delegate;
KProperty var3 = $$delegatedProperties[0];
return (String)var1.getValue();
}
The resulting decompiled bytecode is as follows:
public final class Person {
@NotNull private final String first;
@NotNull private String last;
Setter Parameter use-site targets
As mentioned above, you can use @setparam to add annotations to setter parameters.
Let's compare @set and @setparam in the same example so you can clearly see the difference.
annotation class SetParamAnnotation
annotation class SetAnnotation
Keywords
kotlin, android
Interested in Learning More?
Article Analysis is at the foundation of powerful media monitoring and insights. Learn what you can build with powerful curated search engines, real-time listening and trend analysis on the topics, markets and companies critical to your organization.