1/*
2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package java.beans;
27
28import java.lang.annotation.Documented;
29import java.lang.annotation.Retention;
30import java.lang.annotation.Target;
31
32import static java.lang.annotation.ElementType.METHOD;
33import static java.lang.annotation.RetentionPolicy.RUNTIME;
34
35/**
36 * An annotation used to specify some property-related information for the
37 * automatically generated {@link BeanInfo} classes. This annotation is not used
38 * if the annotated class has a corresponding user-defined {@code BeanInfo}
39 * class, which does not imply the automatic analysis. If both the read and the
40 * write methods of the property are annotated, then the read method annotation
41 * will have more priority and replace the write method annotation.
42 *
43 * @author Sergey A. Malenkov
44 * @see BeanInfo#getPropertyDescriptors
45 * @since 9
46 */
47@Documented
48@Target({METHOD})
49@Retention(RUNTIME)
50public @interface BeanProperty {
51    /**
52     * The value that indicates whether the annotated property can be
53     * a {@link PropertyDescriptor#isBound bound} property or not.
54     * This value applies only to the beans that have the
55     * {@link PropertyChangeListener propertyChange} event set.
56     *
57     * @return {@code true} if the annotated property can be a bound property;
58     *         {@code false} otherwise.
59     */
60    boolean bound() default true;
61
62    /**
63     * The value that indicates whether the annotated property is
64     * an {@link PropertyDescriptor#isExpert expert} property or not.
65     *
66     * @return {@code true} if the annotated property is an expert property;
67     *         {@code false} otherwise.
68     */
69    boolean expert() default false;
70
71    /**
72     * The value that indicates whether the annotated property is
73     * a {@link PropertyDescriptor#isHidden hidden} property or not.
74     *
75     * @return {@code true} if the annotated property is a hidden property;
76     *         {@code false} otherwise.
77     */
78    boolean hidden() default false;
79
80    /**
81     * The value that indicates whether the annotated property is
82     * a {@link PropertyDescriptor#isPreferred preferred} property or not.
83     *
84     * @return {@code true} if the annotated property is a preferred property;
85     *         {@code false} otherwise.
86     */
87    boolean preferred() default false;
88
89    /**
90     * The value that indicates whether the annotated property is
91     * a required property or not.
92     *
93     * @return {@code true} if the annotated property is a required property;
94     *         {@code false} otherwise.
95     */
96    boolean required() default false;
97
98    /**
99     * The value that indicates whether the corresponding component
100     * is repainted after the annotated property got changed or not.
101     *
102     * @return {@code true} if the corresponding component is repainted;
103     *         {@code false} otherwise.
104     */
105    boolean visualUpdate() default false;
106
107    /**
108     * The {@link PropertyDescriptor#getShortDescription short description}
109     * for the {@link BeanInfo#getPropertyDescriptors descriptor}
110     * of the annotated property.
111     *
112     * @return the property description,
113     *         or an empty string if the description is not set.
114     */
115    String description() default "";
116
117    /**
118     * The array of names for the public static fields
119     * that contains the valid values of the annotated property.
120     * These names are used to generate the {@code enumerationValues}
121     * {@link java.beans.BeanDescriptor#getValue feature attribute}
122     * that must contain the following items per each property value:
123     * a displayable name for the property value, the actual property value,
124     * and a Java code piece used for the code generator.
125     *
126     * @return the names of the valid values of the annotated property,
127     *         or an empty array if the names are not provided.
128     */
129    String[] enumerationValues() default {};
130}
131