1

抽象クラスまたはインターフェースを作成していて、抽象メソッドの詳細を提供したい場合、そのメソッドの抽象クラス/インターフェースからコメントを自動インポートする方法はありますか?

例: LetterimplementsShippableで、コメントを自動インポートしたい。については知ってい${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;
        }

}
4

1 に答える 1

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;
    }
}
于 2012-11-14T18:10:05.297 に答える