In Lombok, what is the actual difference between
@Getter(AccessLevel.PACKAGE)
private int country;
and
@Getter(AccessLevel.MODULE)
private int country;
?
That is a good question. I tried creating some setters for some test methods and all I got was (decompiled):
for Module AccessLevel:
void setTestModule(Integer testModule) {
this.testModule = testModule;
}
for Package AccessLevel:
void setTestPackage(Integer testPackage) {
this.testPackage = testPackage;
}
So, on first look it appears that there is no difference. So, I looked into the source code and all I could verify is that for the time being they are handled the same (from the source here):
lombok.javac.handlers.JavacHandlerUtil.toJavacModifier(AccessLevel accessLevel) or lombok.eclipse.handlers.EclipseHandlerUtil.toEclipseModifier(AccessLevel accessLevel)
/**
* Turns an {@code AccessLevel} instance into the flag bit used by javac.
*/
public static int toJavacModifier(AccessLevel accessLevel) {
switch (accessLevel) {
case MODULE:
case PACKAGE:
return 0;
default:
case PUBLIC:
return Flags.PUBLIC;
case NONE:
case PRIVATE:
return Flags.PRIVATE;
case PROTECTED:
return Flags.PROTECTED;
}
}
I think that there will be some future work on that for java 9 probably, but for now it appears to be the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With