@Deprecated(注解) | 您所在的位置:网站首页 › idea注解不可用怎么办 › @Deprecated(注解) |
随着项目的迭代和更新,项目中的类、方法或者字段不建议大家继续使用时,我们通常会使用@Deprecated注解。 @Deprecated表示此内容已废弃、暂时可用,但以后此内容都不会再更新或之后版本可能会被删除,建议后来人不要调用此方法。一般我们都需要在有这个注解上面添加注释,说明当前功能应该使用何种方法达到同样的效果,例如: /** * Allows a model property to be designated as read only. * * @deprecated As of 1.5.19, replaced by {@link #accessMode()} * */ @Deprecated boolean readOnly() default false; /** * Allows to specify the access mode of a model property (AccessMode.READ_ONLY, READ_WRITE) * * @since 1.5.19 */ AccessMode accessMode() default AccessMode.AUTO;java 9以后版本添加了两个属性:since 和 forRemoval。 since: 指定已注解的API元素已被弃用的版本。 forRemoval: 默认是false,如果为true则表示下一个版本将被删除 /** * Allows a model property to be designated as read only. * * @deprecated As of 1.5.19, replaced by {@link #accessMode()} * */ @Deprecated(since = "1.5.19", forRemoval = true) boolean readOnly() default false; /** * Allows to specify the access mode of a model property (AccessMode.READ_ONLY, READ_WRITE) * * @since 1.5.19 */ AccessMode accessMode() default AccessMode.AUTO; |
CopyRight 2018-2019 实验室设备网 版权所有 |