Package lombok

Annotation Type Getter


  • @Target({FIELD,TYPE})
    @Retention(SOURCE)
    public @interface Getter
    Put on any field to make lombok build a standard getter.

    Complete documentation is found at the project lombok features page for @Getter and @Setter.

    Even though it is not listed, this annotation also has the onMethod parameter. See the full documentation for more details.

    Example:

         private @Getter int foo;
     
    will generate:
         public int getFoo() {
             return this.foo;
         }
     

    This annotation can also be applied to a class, in which case it'll be as if all non-static fields that don't already have a @Getter annotation have the annotation.

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean lazy  
      Getter.AnyAnnotation[] onMethod
      Any annotations listed here are put on the generated method.
      AccessLevel value
      If you want your getter to be non-public, you can specify an alternate access level here.
    • Element Detail

      • value

        AccessLevel value
        If you want your getter to be non-public, you can specify an alternate access level here.
        Returns:
        The getter method will be generated with this access modifier.
        Default:
        lombok.AccessLevel.PUBLIC
      • onMethod

        Getter.AnyAnnotation[] onMethod
        Any annotations listed here are put on the generated method. The syntax for this feature depends on JDK version (nothing we can do about that; it's to work around javac bugs).
        up to JDK7:
        @Getter(onMethod=@__({@AnnotationsGoHere}))
        from JDK8:
        @Getter(onMethod_={@AnnotationsGohere}) // note the underscore after onMethod.
        Returns:
        List of annotations to apply to the generated getter method.
        Default:
        {}
      • lazy

        boolean lazy
        Default:
        false