如何将所有已实现的方法标记为已弃用
我有一个带有默认方法实现的抽象类,可以被子类覆盖。但随着时间的推移,这种方法变得荒谬,所以我将其标记为已弃用。但此警告对于已实现的类不可见。对于其他开发人员来说,IT 将更容易轻松地找到弃用警告并删除方法实现并测试他们的模块。 那么有没有一种方法可以将所有已实现的方法一次性标记为已弃用呢?如果这个问题已经存在于 SO 中,我提前表示歉意。
I have an abstract class with a default method implementation which can be overridden by sub classes. But over time this method has become absurd ,so i marked it deprecated. But this warning is not visible for implemented classes. IT would be lot easier for other developers to easily find out deprecation warning and remove the method implementation and test their module.
So is there a way to mark all the implemented methods as deprecated in one go? My apologies in advance if this question is already present in SO.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于该方法本身被您认为已弃用,并且我们正在讨论抽象类,因此您在某种程度上改变了其目的和/或概念逻辑,因此您应该将已弃用的注释应用于抽象类本身,并使用以下命令创建一个新的抽象类应该实现以供将来使用的新的适当抽象方法集。
通过这样做,任何扩展它的类都会在大多数 IDE 中触发适当的弃用警告。
Since the method itself is considered deprecated by you and we are talking about an abstract class, you are somewhat changing its purpose and/or conceptual logic, so you should apply the deprecated annotation to the abstract class itself, and create a new abstract class with the new appropriate set of abstract methods that should be implemented for future usage.
By doing this, any classes that extend it will trigger the appropriate deprecated warning in most IDEs.