diff options
author | Roel Spilker <r.spilker@gmail.com> | 2018-06-18 23:46:42 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2018-06-18 23:56:27 +0200 |
commit | f241ef8c309b90faacabe66431b9deaebfd7087a (patch) | |
tree | 7b46ee984c385ab49930e6721ab390eac285ce13 /src | |
parent | 2264ce492c77f92c03bf75a6c209ed240b247d09 (diff) | |
download | lombok-f241ef8c309b90faacabe66431b9deaebfd7087a.tar.gz lombok-f241ef8c309b90faacabe66431b9deaebfd7087a.tar.bz2 lombok-f241ef8c309b90faacabe66431b9deaebfd7087a.zip |
Transient fields should by default be excluded from equals and hashCode. Fixes #1724
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/core/handlers/InclusionExclusionUtils.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/lombok/core/handlers/InclusionExclusionUtils.java b/src/core/lombok/core/handlers/InclusionExclusionUtils.java index 8d6c717f..368b51fc 100644 --- a/src/core/lombok/core/handlers/InclusionExclusionUtils.java +++ b/src/core/lombok/core/handlers/InclusionExclusionUtils.java @@ -106,7 +106,7 @@ public class InclusionExclusionUtils { return name; } - public static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N, I extends Annotation> List<Included<L, I>> handleIncludeExcludeMarking(Class<I> inclType, String replaceName, Class<? extends Annotation> exclType, LombokNode<A, L, N> typeNode, AnnotationValues<?> annotation, LombokNode<A, L, N> annotationNode) { + public static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N, I extends Annotation> List<Included<L, I>> handleIncludeExcludeMarking(Class<I> inclType, String replaceName, Class<? extends Annotation> exclType, LombokNode<A, L, N> typeNode, AnnotationValues<?> annotation, LombokNode<A, L, N> annotationNode, boolean includeTransient) { List<String> oldExcludes = (annotation != null && annotation.isExplicit("exclude")) ? annotation.getAsStringList("exclude") : null; List<String> oldIncludes = (annotation != null && annotation.isExplicit("of")) ? annotation.getAsStringList("of") : null; @@ -175,6 +175,7 @@ public class InclusionExclusionUtils { } if (child.getKind() != Kind.FIELD) continue; if (child.isStatic()) continue; + if (child.isTransient() && !includeTransient) continue; if (name.startsWith("$")) continue; if (child.isEnumMember()) continue; members.add(new Included<L, I>(child, null, true)); @@ -200,7 +201,7 @@ public class InclusionExclusionUtils { } public static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N> List<Included<L, ToString.Include>> handleToStringMarking(LombokNode<A, L, N> typeNode, AnnotationValues<ToString> annotation, LombokNode<A, L, N> annotationNode) { - List<Included<L, ToString.Include>> members = handleIncludeExcludeMarking(ToString.Include.class, "name", ToString.Exclude.class, typeNode, annotation, annotationNode); + List<Included<L, ToString.Include>> members = handleIncludeExcludeMarking(ToString.Include.class, "name", ToString.Exclude.class, typeNode, annotation, annotationNode, true); Collections.sort(members, new Comparator<Included<L, ToString.Include>>() { @Override public int compare(Included<L, ToString.Include> a, Included<L, ToString.Include> b) { @@ -222,6 +223,6 @@ public class InclusionExclusionUtils { } public static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N> List<Included<L, EqualsAndHashCode.Include>> handleEqualsAndHashCodeMarking(LombokNode<A, L, N> typeNode, AnnotationValues<EqualsAndHashCode> annotation, LombokNode<A, L, N> annotationNode) { - return handleIncludeExcludeMarking(EqualsAndHashCode.Include.class, "replaces", EqualsAndHashCode.Exclude.class, typeNode, annotation, annotationNode); + return handleIncludeExcludeMarking(EqualsAndHashCode.Include.class, "replaces", EqualsAndHashCode.Exclude.class, typeNode, annotation, annotationNode, false); } } |