NameOf

com.github.dwickern.macros.NameOf
See theNameOf companion object
trait NameOf

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object NameOf

Members list

Value members

Concrete methods

transparent inline def nameOf(inline expr: Any): String

Obtain an identifier name as a constant string.

Obtain an identifier name as a constant string.

Example usage:

 val amount = 5
 nameOf(amount) => "amount"

Attributes

transparent inline def nameOf[T](inline expr: T => Any): String

Obtain an identifier name as a constant string.

Obtain an identifier name as a constant string.

This overload can be used to access an instance method without having an instance of the type.

Example usage:

 class Person(val name: String)
 nameOf[Person](_.name) => "name"

Attributes

transparent inline def nameOfType[T]: String

Obtain a type's unqualified name as a constant string.

Obtain a type's unqualified name as a constant string.

Example usage:

 nameOfType[String] => "String"
 nameOfType[fully.qualified.ClassName] => "ClassName"

Attributes

transparent inline def qualifiedNameOf[T](inline expr: T => Any): String

Obtain a fully qualified identifier name as a constant string.

Obtain a fully qualified identifier name as a constant string.

This overload can be used to access an instance method without having an instance of the type.

Example usage:

 class Pet(val age: Int)
 class Person(val name: String, val pet: Pet)
 nameOf[Person](_.pet.age) => "pet.age"

Attributes

transparent inline def qualifiedNameOfType[T]: String

Obtain a type's qualified name as a constant string.

Obtain a type's qualified name as a constant string.

Example usage:

 nameOfType[String] => "java.lang.String"
 nameOfType[fully.qualified.ClassName] => "fully.qualified.ClassName"

Attributes