Packages

object Annotations

Utility methods for dealing with java.lang.annotation.Annotation

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Annotations
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals[A <: Annotation](annotation: Annotation)(implicit arg0: ClassTag[A]): Boolean

    Determines if the given Annotation has an annotation type of the given type param.

    Determines if the given Annotation has an annotation type of the given type param.

    A

    the type to match against.

    annotation

    the Annotation to match.

    returns

    true if the given Annotation is of type A, false otherwise.

  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def filterAnnotations(filterSet: Set[Class[_ <: Annotation]], annotations: Array[Annotation]): Array[Annotation]

    Filters a list of annotations by annotation type discriminated by the set of given annotations.

    Filters a list of annotations by annotation type discriminated by the set of given annotations.

    filterSet

    the Set of Annotation classes by which to filter.

    annotations

    the list Annotation instances to filter.

    returns

    the filtered list of matching annotations.

  10. def filterIfAnnotationPresent[A <: Annotation](annotations: Array[Annotation])(implicit arg0: ClassTag[A]): Array[Annotation]

    Filter a list of annotations discriminated on whether the annotation is itself annotated with the passed annotation.

    Filter a list of annotations discriminated on whether the annotation is itself annotated with the passed annotation.

    A

    the type of the annotation by which to filter.

    annotations

    the list of Annotation instances to filter.

    returns

    the filtered list of matching annotations.

  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  12. def findAnnotation[A <: Annotation](annotations: Array[Annotation])(implicit arg0: ClassTag[A]): Option[A]

    Find an Annotation within a given list of annotations annotated by the given type param.

    Find an Annotation within a given list of annotations annotated by the given type param.

    A

    the type of the Annotation to find.

    annotations

    the list of Annotation instances to search.

    returns

    the matching Annotation instance if found, otherwise None.

  13. def findAnnotation(target: Class[_ <: Annotation], annotations: Array[Annotation]): Option[Annotation]

    Find an Annotation within a given list of annotations of the given target.

    Find an Annotation within a given list of annotations of the given target. annotation type.

    target

    the class of the Annotation to find.

    annotations

    the list of Annotation instances to search.

    returns

    the matching Annotation instance if found, otherwise None.

  14. def findAnnotations(clazz: Class[_], parameterTypes: Seq[Class[_]] = Seq.empty): Map[String, Array[Annotation]]

    Attempts to map fields to array of annotations.

    Attempts to map fields to array of annotations. This is intended to work around the Scala default of not carrying annotation information on annotated constructor fields annotated without also specifying a @meta annotation (e.g., @field). Thus, this method scans the constructor and then all declared fields in order to build up the mapping of field name to Array[java.lang.Annotation]. When the given class has a single constructor, that constructor will be used. Otherwise, the given parameter types are used to locate a constructor. Steps:

    • walk the constructor and collect annotations on all parameters.
    • for each declared field in the class, collect declared annotations. If a constructor parameter is overridden as a declared field, the annotations on the declared field take precedence.
    • for each super interface, walk each declared method, collect declared method annotations IF the declared method is the same name of a declared field from step two. That is find only super interface methods which are implemented by declared fields in the given class in order to locate inherited annotations for the declared field.
    clazz

    the Class to inspect. This should represent a Scala case class.

    parameterTypes

    an optional list of parameter class types in order to locate the appropriate case class constructor when the class has multiple constructors. If a class has multiple constructors and parameter types are not specified, an IllegalArgumentException is thrown. Likewise, if a suitable constructor cannot be located by the given parameter types an IllegalArgumentException is thrown.

    returns

    a map of field name to associated annotations. An entry in the map only occurs if the associated annotations are non-empty. That is fields without any found annotations are not returned.

    See also

    https://www.scala-lang.org/api/current/scala/annotation/meta/index.html

  15. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def getValue(annotation: Annotation, method: String = "value"): Option[String]

    Attempts to return the result of invoking method() of a given Annotation.

    Attempts to return the result of invoking method() of a given Annotation. If the Annotation#method cannot be invoked then None is returned.

    annotation

    the Annotation to process.

    method

    the method of the Annotation to invoke to obtain a value.

    returns

    the result of invoking annotation#method() or None.

  17. def getValueIfAnnotatedWith[A <: Annotation](annotation: Annotation, method: String = "value")(implicit arg0: ClassTag[A]): Option[String]

    Attempts to return the result of invoking method() of a given Annotation which should be annotated by an Annotation of type A.

    Attempts to return the result of invoking method() of a given Annotation which should be annotated by an Annotation of type A.

    If the given Annotation is not annotated by an Annotation of type A or if the Annotation#method cannot be invoked then None is returned.

    A

    the Annotation type to match against before trying to invoke annotation#method.

    annotation

    the Annotation to process.

    method

    the method of the Annotation to invoke to obtain a value.

    returns

    the result of invoking annotation#method() or None.

  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. def isAnnotationPresent[ToFindAnnotation <: Annotation, A <: Annotation](implicit arg0: ClassTag[ToFindAnnotation], arg1: ClassTag[A]): Boolean

    Determines if the given A is annotated by an Annotation of the given type param ToFindAnnotation.

    Determines if the given A is annotated by an Annotation of the given type param ToFindAnnotation.

    ToFindAnnotation

    the Annotation to match.

    A

    the type of the Annotation to determine if is annotated on the A.

    returns

    true if the given Annotation is annotated with an Annotation of type ToFindAnnotation, false otherwise.

  20. def isAnnotationPresent[A <: Annotation](annotation: Annotation)(implicit arg0: ClassTag[A]): Boolean

    Determines if the given Annotation is annotated by an Annotation of the given type param.

    Determines if the given Annotation is annotated by an Annotation of the given type param.

    A

    the type of the Annotation to determine if is annotated on the Annotation.

    annotation

    the Annotation to match.

    returns

    true if the given Annotation is annotated with an Annotation of type A, false otherwise.

  21. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  22. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  25. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  26. def toString(): String
    Definition Classes
    AnyRef → Any
  27. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped