import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; public class GetterSetterExample { private @Getter @Setter int age = 10; private @Setter(AccessLevel.PROTECTED) String name; @Override public String toString() { return String.format("%s (age: %d)", age, name); } }