mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 00:14:50 +00:00
Fix for issue 376 for Eclipse
This commit is contained in:
1 parent
78bf0f6fbb
commit
37cbe2d3f9
3 files changed
+17
-4
No files matched your search
@@ -774,9 +774,19 @@ public class EclipseHandlerUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<FieldDeclaration, GetterMethod> generatedLazyGetters = new WeakHashMap<FieldDeclaration, GetterMethod>();
|
||||
|
||||
static void registerCreatedLazyGetter(FieldDeclaration field, char[] methodName, TypeReference returnType) {
|
||||
generatedLazyGetters.put(field, new GetterMethod(methodName, returnType));
|
||||
}
|
||||
|
||||
private static GetterMethod findGetter(EclipseNode field) {
|
||||
TypeReference fieldType = ((FieldDeclaration)field.get()).type;
|
||||
FieldDeclaration fieldDeclaration = (FieldDeclaration) field.get();
|
||||
GetterMethod gm = generatedLazyGetters.get(fieldDeclaration);
|
||||
if (gm != null) return gm;
|
||||
TypeReference fieldType = fieldDeclaration.type;
|
||||
boolean isBoolean = nameEquals(fieldType.getTypeName(), "boolean") && fieldType.dimensions() == 0;
|
||||
|
||||
EclipseNode typeNode = field.up();
|
||||
for (String potentialGetterName : toAllGetterNames(field, isBoolean)) {
|
||||
for (EclipseNode potentialGetter : typeNode.down()) {
|
||||
|
||||
@@ -268,6 +268,9 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
|
||||
method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart;
|
||||
method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd;
|
||||
method.statements = statements;
|
||||
|
||||
EclipseHandlerUtil.registerCreatedLazyGetter((FieldDeclaration) fieldNode.get(), method.selector, returnType);
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class GetterLazyBoolean {
|
||||
@lombok.EqualsAndHashCode(of = "booleanValue") @lombok.ToString(of = "booleanValue") class GetterLazyBoolean {
|
||||
private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>> booleanValue = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>>();
|
||||
private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>> otherBooleanValue = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>>();
|
||||
public @java.lang.SuppressWarnings("all") boolean isBooleanValue() {
|
||||
@@ -43,7 +43,7 @@ class GetterLazyBoolean {
|
||||
final @java.lang.SuppressWarnings("all") GetterLazyBoolean other = (GetterLazyBoolean) o;
|
||||
if ((! other.canEqual((java.lang.Object) this)))
|
||||
return false;
|
||||
if (this.isBooleanValue() != other.isBooleanValue())
|
||||
if ((this.isBooleanValue() != other.isBooleanValue()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class GetterLazyBoolean {
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * PRIME + (this.isBooleanValue() ? 1231 : 1237);
|
||||
result = ((result * PRIME) + (this.isBooleanValue() ? 1231 : 1237));
|
||||
return result;
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
|
||||
|
||||
Reference in new issue
Block a user