Properties
A PropertyDescriptor describes one property: its type, whether it can be read and written, its visibility and its annotations. The accessor is only there when you asked for accessors.
Members
What becomes a property
vals, vars and parameterless defs of a class are properties. A var is writable, everything else read-only.
Account, live
Every property the macro found, with type, visibility and access.
- masked
- java.lang.String · public · read-only
- number
- java.lang.String · public · read-only
- owner
- java.lang.String · public · read/write
scala
class Account {
var owner: String = "Ada"
val number: String = "DE-001"
protected var level: Int = 1
private var pin: Int = 1234
def masked: String = s"****${pin % 100}"
}
ReflectMacros.reflect[Account].properties
Filters
Readable and writable sets
The descriptor filters for you. getWriteableProperties is what a form or a JSON reader needs, getReadableProperties what a view or a writer needs.
- account.getWriteableProperties.map(_.name)
- owner
- account.hasProperty("owner")
- true
- account.getProperty("owner").flatMap(_.accessor)
- None
- name · propertyType
- The name and a TypeDescriptor of the type.
- isReadable · isWriteable
- Whether a getter and a setter exist.
- isPublic · isProtected · isPrivate
- The declared visibility.
- annotations · getAnnotation(name) · hasAnnotation(name)
- Annotations with their arguments.
- accessor: Option[PropertyAccessor[Any, Any]]
- Only filled by reflectWithAccessors and the registry.