当前位置:网站首页>Kotlin annotations
Kotlin annotations
2022-08-08 20:32:00 【Don't forget the original intention of z】
Article table of contents
Annotations
Basic Notes
@JvaName
@JvaField
@JvnStatic
@JvmOverloads
@Throws
Meta annotation
Four Kotlin meta-annotations
@Target
Annotation classes corresponding to target annotations are kotlin.annotation.Target Specifies the applicable target of a new annotation
The allowedTargets attribute is used to set the applicable target, this property has 15 constants
@Retention
Retention period annotation, specifying the valid range of a new annotation
value attribute, which is used to set the retention period, there are three enumeration constants
@Repeatable
Repeatable annotation, which allows repeated annotations in the same program element, repeatable annotations must be annotated with this @Repeatable
@MustBeDocumented
Document annotations, which can decorate code elements (classes, interfaces, functions, properties, etc.), and document generation tools can extract these annotation information
Custom annotations
The simplest custom annotation code:
annotation calss annotation name declares annotation
annotation calss annotation name (val value: String') declares an annotation with attributes
annotation calss annotation name (valvalue: String = "annotation information") declares an annotation with a default value
The use of these custom annotations needs to be constrained with meta-annotations
Annotation target declaration
When multiple elements may be modified, you can use the annotation target declaration to specify the specific element modified by the annotation
Annotation target list
file file
property attribute, which is invisible in java using this target
field field
get getter accessor
set setter accessor
receiver extension function or function parameter
param constructor parameter
setparam setter accessor parameter
delegate save obsceneAttribute fields
Get annotation information through reflection
Get reflection instantiation
val clz = user::class
val ann = clz.findAnnotation get all annotation information
边栏推荐
- PHP使用glob()查找文件
- Matlab用回归、SEIRD模型、聚类预测美国总统大选、新冠疫情对中美经济的影响
- Kotlin中IO流
- 【分享】如何在集简云平台自己进行应用开发?
- 学习笔记:栈的应用1_递归(重点)
- Mendix:企业成功执行数字化转型的9个因素
- C语言关键字入门 这一篇足矣
- 网络工程师怎么系统性学习?这份网工资料包帮你解决
- 关于KotlinAndroid遇到的小知识
- Categorized input and output, Go lang1.18 introductory refining tutorial, from Bai Ding to Hongru, go lang basic data types and input and output EP03
猜你喜欢

NAACL2022 NER SOTA—RICON学习笔记

0-1 背包问题

劳务派遣业务流程图

Yarn 总结(未完待续)

莅临GOPS大会龙智展位,获取Forrester最新报告:《Forrester Wave:2021年第四季度企业服务管理报告》

学习笔记:第三章 栈与队列

梅科尔工作室OpenHarmony设备开发培训笔记-第一章学习笔记

曲面着色器初试--地面轨迹模拟(部分细节不完善)

NAACL2022 NER SOTA - RICON study notes

OpenEuler's Ways to Improve Resource Utilization 02: Effects under Typical Applications
随机推荐
Categorized input and output, Go lang1.18 introductory refining tutorial, from Bai Ding to Hongru, go lang basic data types and input and output EP03
第四讲 SVN
【2023秋招面经】20220805安恒信息实习
自定义MVC
DCT变换
阿里云OSS文件下载到本地指定文件有坑
使用fontforge修改字体,只保留数字
OneNote 教程,如何在 OneNote 中检查拼写?
小白如何购买基金产品?
Cesium中自定义材质material
com.alibaba.fastjson.JSONException: default constructor not found. class
OpenEuler's Ways to Improve Resource Utilization 02: Effects under Typical Applications
XTU OJ 1075 求最小公倍数
Kotlin基础稳固第一天
MySQL8 免安装版安装
Ansible自动化运维工具(一)安装及模块
Kotlin中IO流
Kotlin解析String路径小知识
源码分析MyCat专栏
LeetCode #104.二叉树的最大深度