Transient.java revision 11099:678faa7d1a6a
1/*
2 * Copyright (c) 2008, 2013, 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.Retention;
29import java.lang.annotation.Target;
30
31import static java.lang.annotation.ElementType.METHOD;
32import static java.lang.annotation.RetentionPolicy.RUNTIME;
33
34/**
35 * Indicates that an attribute called "transient"
36 * should be declared with the given {@code value}
37 * when the {@link Introspector} constructs
38 * a {@link PropertyDescriptor} or {@link EventSetDescriptor}
39 * classes associated with the annotated code element.
40 * A {@code true} value for the "transient" attribute
41 * indicates to encoders derived from {@link Encoder}
42 * that this feature should be ignored.
43 * <p>
44 * The {@code Transient} annotation may be used
45 * in any of the methods that are involved
46 * in a {@link FeatureDescriptor} subclass
47 * to identify the transient feature in the annotated class and its subclasses.
48 * Normally, the method that starts with "get" is the best place
49 * to put the annotation and it is this declaration
50 * that takes precedence in the case of multiple annotations
51 * being defined for the same feature.
52 * <p>
53 * To declare a feature non-transient in a class
54 * whose superclass declares it transient,
55 * use {@code @Transient(false)}.
56 * In all cases, the {@link Introspector} decides
57 * if a feature is transient by referring to the annotation
58 * on the most specific superclass.
59 * If no {@code Transient} annotation is present
60 * in any superclass the feature is not transient.
61 *
62 * @since 1.7
63 */
64@Target({METHOD})
65@Retention(RUNTIME)
66public @interface Transient {
67    /**
68     * Returns whether or not the {@code Introspector} should
69     * construct artifacts for the annotated method.
70     * @return whether or not the {@code Introspector} should
71     * construct artifacts for the annotated method
72     */
73    boolean value() default true;
74}
75