About

Accessors are methods. Their role are to return the values of an object's state (a field in Java, a property in Javascript…)

For the same field, you can have several getter:

  • get: to get the value
  • getDefault: to return the default value
  • getOrDefault to return the value or the default

If the creation of object is expensive, you can also have a cache of objects and return the cache instead.

The Get method is the accessor while the Set method is known as the mutator method.