accessor method
A method that returns the value of a field, such as id() on a record or getId() on a JavaBean-style class.
In more detail
Records generate accessors named exactly like their components, with no get prefix, so Point has x() and y(). Ordinary classes and JPA entities traditionally use getX style names. Frameworks such as Jackson use accessors to read an object's data.
Examples
value.id()order.getStatus()Related terms
- record (Java) — A compact Java class for plain data, declared with its components in one line, for which the compiler generates the fields, accessors, equals, hashCode and toString.
- field — A variable declared inside a class that stores part of an object's state.
Taught in
- Primitive And Reference Types — Modern Java: Virtual Threads & High-Throughput Services
- Records And Data Classes — Modern Java: Virtual Threads & High-Throughput Services
- The Streams API — Modern Java: Virtual Threads & High-Throughput Services