如果我正在创建一个抽象类或接口并希望提供一些抽象方法的详细信息,那么有没有办法从该方法的抽象类/接口自动导入注释?
例如:Letter
实现Shippable
,我希望评论能够自动导入。我知道${see_to_overridden}
,我更喜欢直接注入抽象方法的评论
public interface Shippable{
/*
* returns boolean based on your class's criteria for if it needs to be insured
* if your parcel type is not insurable just leave as false
*/
boolean isInsured();
String shippingMethod();
}
public class Letter implements Insurable{
/*
* returns boolean based on your class's criteria for if it needs to be insured
* if your parcel type is not insurable just leave as false
*/
boolean isInsured(){
return false;
}
}
答案 0 :(得分:3)
在子类注释中,您可以使用{@inheritDoc}
来从超类中插入文档。您还需要使您的注释符合JavaDoc约定 - 最重要的是,它们以/**
而不是/*
开头(感谢@Puce指出它)。
public interface Shippable{
/**
* returns boolean based on your class's criteria for if it needs to be insured
* if your parcel type is not insurable just leave as false
*/
boolean isInsured();
String shippingMethod();
}
public class Letter implements Insurable{
/**
* some subclass-specific comments here (optional)
* {@inheritDoc}
* more subclass-specific comments here (optional)
*/
boolean isInsured(){
return false;
}
}