traitAnnotations[A, T] extends DepFn0 with Serializable
Provides the annotations of type A of the fields or constructors of case class-like or sum type T.
If type T is case class-like, this type class inspects its fields and provides their annotations of type A. If
type T is a sum type, its constructor types are looked for annotations.
Type Out is an HList having the same number of elements as T (number of fields of T if T is case class-like,
or number of constructors of T if it is a sum type). It is made of None.type (no annotation on corresponding
field or constructor) and Some[A] (corresponding field or constructor is annotated).
Method apply provides an HList of type Out made of None (corresponding field or constructor not annotated)
or Some(annotation) (corresponding field or constructor has annotation annotation).
Note that annotation types must be case class-like for this type class to take them into account.
Example:
caseclass First(s: String)
caseclass CC(i: Int, @First("a") s: String)
sealedtrait Base
@First("b") caseclass BaseI(i: Int) extends Base
caseclass BaseS(s: String) extends Base
val ccFirsts = Annotations[First, CC]
val baseFirsts = Annotations[First, Base]
// ccFirsts.Out is None.type :: Some[First] :: HNil// ccFirsts.apply() is// None :: Some(First("a")) :: HNil// baseFirsts.Out is Some[First] :: None.type :: HNil// baseFirsts.apply() is// Some(First("b")) :: None :: HNil
Provides the annotations of type
A
of the fields or constructors of case class-like or sum typeT
.If type
T
is case class-like, this type class inspects its fields and provides their annotations of typeA
. If typeT
is a sum type, its constructor types are looked for annotations.Type
Out
is an HList having the same number of elements asT
(number of fields ofT
ifT
is case class-like, or number of constructors ofT
if it is a sum type). It is made ofNone.type
(no annotation on corresponding field or constructor) andSome[A]
(corresponding field or constructor is annotated).Method
apply
provides an HList of typeOut
made ofNone
(corresponding field or constructor not annotated) orSome(annotation)
(corresponding field or constructor has annotationannotation
).Note that annotation types must be case class-like for this type class to take them into account.
Example: