summaryrefslogtreecommitdiff
path: root/src/library/scala/annotation/target/beanSetter.scala
blob: 6f4887aa0cc4f97228b91a3ea66f989c944ea64a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2002-2010, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */
package scala.annotation.target

/**
 * For every field of a class, the Scala compiler generates up to four
 * synthetic accessors: getter, setter, bean getter and bean setter.
 * The meta-annotations in package {{{scala.annotation.target}}} are
 * used to control to which of the above members the annotations on
 * the field are copied. By default, field annotations are only added
 * to the actual field, but not to any of the accessors. By annotating
 * the annotation type or the annotation class with one or several of
 * the meta-annotations this behavior can be changed.
 *
 * In the following example, the annotation {{{@Id}}} will be added
 * only to the bean getter {{{getX}}}. In order to annotate the field
 * as well, the meta-annotation {{{@field}}} would need to be added.
 *
 * {{{
 * import javax.persistence.Id
 * class A {
 *   @(Id @beanGetter) @BeanProperty val x = 0
 * }
 * }}}
 *
 * The syntax can be improved using a type alias:
 *
 * {{{
 * object ScalaJPA {
 *   type Id = javax.persistence.Id @beanGetter
 * }
 * import ScalaJPA.Id
 * class A {
 *   @Id @BeanProperty val x = 0
 * }
 * }}}
 *
 * For annotations defined in Scala, a default target can be specified
 * in the annotation class itself, for example
 *
 * {{{
 * @getter
 * class myAnnotation extends Annotation
 * }}}
 */
final class beanSetter extends annotation.StaticAnnotation