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.TYPE;
  32 import static java.lang.annotation.RetentionPolicy.RUNTIME;
  33 
  34 /**
  35  * An annotation used to specify some class-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#getBeanDescriptor
  42  * @since 1.9
  43  *
  44  * @author Sergey A. Malenkov
  45  */
  46 @Documented
  47 @Target({TYPE})
  48 @Retention(RUNTIME)
  49 public @interface JavaBean {
  50     /**
  51      * The {@link BeanDescriptor#getShortDescription short description}
  52      * for the {@link BeanInfo#getBeanDescriptor bean descriptor}
  53      * of the annotated class.
  54      *
  55      * @return the bean description,
  56      *         or an empty string if the description is not set.
  57      */
  58     String description() default "";
  59 
  60     /**
  61      * The name of the default property is used to calculate its
  62      * {@link BeanInfo#getDefaultPropertyIndex index} in the
  63      * {@link BeanInfo#getPropertyDescriptors array} of properties
  64      * defined in the annotated class. If the name is not set or
  65      * the annotated class does not define a property
  66      * with the specified name, the default property index
  67      * will be calculated automatically by the
  68      * {@link Introspector} depending on its state.
  69      *
  70      * @return the name of the default property,
  71      *         or an empty string if the name is not set.
  72      */
  73     String defaultProperty() default "";
  74 
  75     /**
  76      * The name of the default event set is used to calculate its
  77      * {@link BeanInfo#getDefaultEventIndex index} in the
  78      * {@link BeanInfo#getEventSetDescriptors array} of event sets
  79      * defined in the annotated class. If the name is not set or
  80      * the annotated class does not define an event set
  81      * with the specified name, the default event set index
  82      * will be calculated automatically by the
  83      * {@link Introspector} depending on its state.
  84      *
  85      * @return the name of the default event set,
  86      *         or an empty string if the name is not set.
  87      */
  88     String defaultEventSet() default "";
  89 }