Тип аннотации ConstructorProperties
@Documented @Target(value=CONSTRUCTOR) @Retention(value=RUNTIME) public @interface ConstructorProperties
Аннотация для конструктора, показывающая, как параметры этого конструктора соответствуют методам-геттерам созданного объекта. Например:
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() , а второй — с помощью метода getY() . Поскольку имена параметров, как правило, недоступны во время выполнения, без аннотации не было бы способа узнать, соответствуют ли параметры getX() и getY() или наоборот.- С момента:
- 1.6
Обязательные элементы
| Модификатор и тип | Обязательный элемент и описание |
|---|---|
String[] |
value Имена геттеров. |
Элементы
value
public abstract String[] value
Имена геттеров.
- Возвращает:
- имена геттеров, соответствующие параметрам в аннотированном конструкторе.
© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.