1. Michael Ludwig
  2. entreri
  3. Issues
Issue #53 resolved

Allow property annotations to be placed on getter or setter.

Michael Ludwig
repo owner created an issue

For some properties, it makes sense to think of the getter as the dominant definition. In other cases, such as validation or auto-updating, it seems more consistent if the setter specifies this, because it is the setter method call that performs the increment. However, it also makes sense to allow it on the getter since that is the method "defining" the property and auto-versioning is a property of the property. So both should be allowed.

This decision has some impact on the validation annotations. Originally these must be placed on the setter because they may reference the setter arguments. In some cases like @NotNull and @Within, these are valuable documenting annotations that could go on the getter. When allowed in either place, the developer can choose what makes the most sense, place them on both, etc.