1 /*
   2  * Copyright (c) 2014, 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 package java.beans;
  26 
  27 import java.lang.annotation.Documented;
  28 import java.lang.annotation.Retention;
  29 import java.lang.annotation.Target;
  30 
  31 import static java.lang.annotation.ElementType.METHOD;
  32 import static java.lang.annotation.RetentionPolicy.RUNTIME;
  33 
  34 /**
  35  * An annotation used to specify some property-related information
  36  * for the automatically generated {@link BeanInfo} classes.
  37  * This annotation is not used if the annotated class
  38  * has a corresponding user-defined {@code BeanInfo} class,
  39  * which does not imply the automatic analysis.
  40  *
  41  * @see BeanInfo#getPropertyDescriptors
  42  * @since 1.9
  43  *
  44  * @author Sergey A. Malenkov
  45  */
  46 @Documented
  47 @Target({METHOD})
  48 @Retention(RUNTIME)
  49 public @interface BeanProperty {
  50     /**
  51      * The value that indicates whether the annotated property can be
  52      * a {@link PropertyDescriptor#isBound bound} property or not.
  53      * This value applies only to the beans that have the
  54      * {@link PropertyChangeListener propertyChange} event set.
  55      *
  56      * @return {@code true} if the annotated property can be a bound property;
  57      *         {@code false} otherwise.
  58      */
  59     boolean bound() default true;
  60 
  61     /**
  62      * The value that indicates whether the annotated property is
  63      * an {@link PropertyDescriptor#isExpert expert} property or not.
  64      *
  65      * @return {@code true} if the annotated property is an expert property;
  66      *         {@code false} otherwise.
  67      */
  68     boolean expert() default false;
  69 
  70     /**
  71      * The value that indicates whether the annotated property is
  72      * a {@link PropertyDescriptor#isHidden hidden} property or not.
  73      *
  74      * @return {@code true} if the annotated property is a hidden property;
  75      *         {@code false} otherwise.
  76      */
  77     boolean hidden() default false;
  78 
  79     /**
  80      * The value that indicates whether the annotated property is
  81      * a {@link PropertyDescriptor#isPreferred preferred} property or not.
  82      *
  83      * @return {@code true} if the annotated property is a preferred property;
  84      *         {@code false} otherwise.
  85      */
  86     boolean preferred() default false;
  87 
  88     /**
  89      * The value that indicates whether the annotated property is
  90      * a required property or not.
  91      *
  92      * @return {@code true} if the annotated property is a required property;
  93      *         {@code false} otherwise.
  94      */
  95     boolean required() default false;
  96 
  97     /**
  98      * The value that indicates whether the corresponding component
  99      * is repainted after the annotated property got changed or not.
 100      *
 101      * @return {@code true} if the corresponding component is repainted;
 102      *         {@code false} otherwise.
 103      */
 104     boolean visualUpdate() default false;
 105 
 106     /**
 107      * The {@link PropertyDescriptor#getShortDescription short description}
 108      * for the {@link BeanInfo#getPropertyDescriptors descriptor}
 109      * of the annotated property.
 110      *
 111      * @return the property description,
 112      *         or an empty string if the description is not set.
 113      */
 114     String description() default "";
 115 
 116     /**
 117      * The array of names for the public static fields
 118      * that contains the valid values of the annotated property.
 119      * These names are used to generate the {@code enumerationValues}
 120      * {@link java.beans.BeanDescriptor#getValue feature attribute}
 121      * that must contain the following items per each property value:
 122      * a displayable name for the property value, the actual property value,
 123      * and a Java code piece used for the code generator.
 124      *
 125      * @return the names of the valid values of the annotated property,
 126      *         or an empty array if the names are not provided.
 127      */
 128     String[] enumerationValues() default {};
 129 }