モジュール java.desktop
パッケージ java.beans

注釈インタフェースConstructorProperties


@Documented @Target(CONSTRUCTOR) @Retention(RUNTIME) public @interface ConstructorProperties

コンストラクタの注釈。構築されたオブジェクトのgetterメソッドにこのコンストラクタのパラメータがどのように対応するかを示します。 次に例を示します。

   public class Point {
       @ConstructorProperties({"x", "y"})
       public Point(int x, int y) {
           this.x = x;
           this.y = y;
       }

       public int getX() {
           return x;
       }

       public int getY() {
           return y;
       }

       private final int x, y;
   }
注釈は、コンストラクタの最初のパラメータはgetX()メソッドで取得でき、2番目のパラメータはgetY()メソッドで取得できることを示します。 一般にパラメータ名は実行時に利用できないため、注釈がないと、パラメータがgetX()およびgetY()に対応するかどうかやその逆について知る方法はありません。

導入されたバージョン:
1.6
  • 必須要素のサマリー

    必須要素
    修飾子と型
    必須要素
    説明
    getterの名前。
  • 要素の詳細

    • value

      String[] value

      getterの名前。

      戻り値:
      注釈が付けられたコンストラクタのパラメータに対応するgetterの名前。