需求:有些基础类型的遍历,值希望它被赋予指定的几个值,赋予其他值能够别编译器(IDEA/eclipse)提醒
Android studu结合自己的插件,引入
<!-- https://mvnrepository.com/artifact/com.android.support/support-annotations --> <dependency> <groupId>com.android.support</groupId> <artifactId>support-annotations</artifactId> <version>22.0.0</version> </dependency>
使用@IntDef/@StringDef可以满足需求
idea也有类似的:
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations --> <dependency> <groupId>org.jetbrains</groupId> <artifactId>annotations</artifactId> <version>17.0.0</version> </dependency>
有个问题,android的满足需求,但是不能用到IDEA,idea上的静态代码分析,又不能满足需求,记一下,回头解决
原文:https://www.cnblogs.com/donfaquir/p/11177244.html