フィールドに注釈を使用するオブジェクトの永続化のための Java API を開発していますが、クラスに関するより良い実装が何であるかはわかりません。
public interface Persistent{        
        public Key getKey();
    public void setKey(Key key);
}
public class PersistentObject implements Persistent{
    Key key;        
    public Key getKey() {
        return key;
    }
    public void setKey(Key key) {
        this.key=key;
    }       
}
また
public @interface Persistent {  
}
@Persistent
public class PersistentObject {
    Key key; //the coder must create this variable or the system doesn't work
}
- 最初のものは、OOP で広く使用されているインターフェイス メカニズムを使用します。このインターフェイスを実装するには、変数を作成する必要がありますが、プログラマーはそれを知っていると想定されています。
 - 2 番目の方法は、最終的なプログラマーにとってより簡単であり、永続化のために多くのライブラリで広く使用されていますが、プログラマーは慣例により、OOP モデルに適合しない 1 つの名前で変数を作成する必要があります。
 
回答ありがとうございます。