diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2009-12-04 08:23:11 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2009-12-04 08:23:11 +0000 |
commit | 0e9c5b7f850d90117cab870d340c2b46cf73586b (patch) | |
tree | 3f8adce1a04efcb641d0eec28502a016dfabf633 /src/library | |
parent | 7feaefb229d567a5f56e8a29746d49db77f63314 (diff) | |
download | scala-0e9c5b7f850d90117cab870d340c2b46cf73586b.tar.gz scala-0e9c5b7f850d90117cab870d340c2b46cf73586b.tar.bz2 scala-0e9c5b7f850d90117cab870d340c2b46cf73586b.zip |
close #2708
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/annotation/target/param.scala | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/library/scala/annotation/target/param.scala b/src/library/scala/annotation/target/param.scala new file mode 100644 index 0000000000..821bd81eba --- /dev/null +++ b/src/library/scala/annotation/target/param.scala @@ -0,0 +1,51 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2009, 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 param extends StaticAnnotation |