Annotation Interface AccessorsStyle


Annotate a class (typically a Java Bean) to make it explicit the style of its accessors when not using the standard getter and setters:
 @AccessorsStyle(readPrefixes = {""}, writePrefixes = {""})
 public class Person {

     private String name;
     private int age;

     public Person(String name, int age) {
         this.name = name;
         this.age = age;
     }

     public String name() {
         return this.name;
     }

     public void name(String name) {
         this.name = name;
     }

     public int age() {
         return this.age;
     }

     public void age(int age) {
         this.age = age;
     }
 }

Defining the readPrefixes and writePrefixes as empty strings makes Micronaut aware of those accessors. It is also possible to annotate fields with this annotation but the usage is only limited when using it with @ConfigurationBuilder.

Since:
3.3.0
Author:
Iván López
  • Field Details

  • Element Details

    • readPrefixes

      String[] readPrefixes
      Returns:
      The valid read prefixes.
      Default:
      {"get"}
    • writePrefixes

      String[] writePrefixes
      Returns:
      The valid write prefixes.
      Default:
      {"set"}