mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-11 03:13:38 +00:00
Update handlers to account for pre-existing @JsonIgnore annotations
This commit is contained in:
1 parent
f5cf267d02
commit
5ceb5f5e89
2 files changed
+16
-12
No files matched your search
@@ -188,15 +188,20 @@ public class HandleJacksonized extends EclipseAnnotationHandler<Jacksonized> {
|
||||
// Add @JsonProperty to all fields. It will be automatically copied to the getter/setters later.
|
||||
for (EclipseNode eclipseNode : tdNode.down()) {
|
||||
if (eclipseNode.getKind() == Kind.FIELD) {
|
||||
if (eclipseNode.isTransient()) createJsonIgnoreForField(eclipseNode, annotationNode);
|
||||
else createJsonPropertyForField(eclipseNode, annotationNode);
|
||||
if (JacksonAnnotations.JSON_PROPERTY.isAnnotating(eclipseNode) ||
|
||||
JacksonAnnotations.JSON_IGNORE.isAnnotating(eclipseNode)) {
|
||||
return;
|
||||
} else if (eclipseNode.isTransient()) {
|
||||
createJsonIgnoreForField(eclipseNode, annotationNode);
|
||||
} else {
|
||||
createJsonPropertyForField(eclipseNode, annotationNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
tdNode.rebuild();
|
||||
}
|
||||
|
||||
private void createJsonPropertyForField(EclipseNode fieldNode, EclipseNode annotationNode) {
|
||||
if (JacksonAnnotations.JSON_PROPERTY.isAnnotating(fieldNode)) return;
|
||||
ASTNode astNode = fieldNode.get();
|
||||
if (astNode instanceof FieldDeclaration) {
|
||||
FieldDeclaration fd = (FieldDeclaration)astNode;
|
||||
@@ -206,7 +211,6 @@ public class HandleJacksonized extends EclipseAnnotationHandler<Jacksonized> {
|
||||
}
|
||||
|
||||
private void createJsonIgnoreForField(EclipseNode fieldNode, EclipseNode annotationNode) {
|
||||
if (JacksonAnnotations.JSON_IGNORE.isAnnotating(fieldNode)) return;
|
||||
ASTNode astNode = fieldNode.get();
|
||||
if (astNode instanceof FieldDeclaration) {
|
||||
FieldDeclaration fd = (FieldDeclaration)astNode;
|
||||
|
||||
@@ -122,16 +122,19 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
|
||||
// Add @JsonIgnore to all transient fields. It will be automatically copied to the getter/setters later.
|
||||
for (JavacNode javacNode : tdNode.down()) {
|
||||
if (javacNode.getKind() == Kind.FIELD) {
|
||||
if (javacNode.isTransient()) createJsonIgnoreForField(javacNode, annotationNode);
|
||||
else createJsonPropertyForField(javacNode, annotationNode);
|
||||
if (JacksonAnnotations.JSON_PROPERTY.isAnnotating(javacNode) ||
|
||||
JacksonAnnotations.JSON_IGNORE.isAnnotating(javacNode)) {
|
||||
return;
|
||||
} else if (javacNode.isTransient()) {
|
||||
createJsonIgnoreForField(javacNode, annotationNode);
|
||||
} else {
|
||||
createJsonPropertyForField(javacNode, annotationNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createJsonPropertyForField(JavacNode fieldNode, JavacNode annotationNode) {
|
||||
if (JacksonAnnotations.JSON_PROPERTY.isAnnotating(fieldNode)) {
|
||||
return;
|
||||
}
|
||||
JavacTreeMaker maker = fieldNode.getTreeMaker();
|
||||
|
||||
JCExpression jsonPropertyType = chainDots(fieldNode, JacksonAnnotations.JSON_PROPERTY.chainedDots);
|
||||
@@ -142,9 +145,6 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
|
||||
}
|
||||
|
||||
private void createJsonIgnoreForField(JavacNode fieldNode, JavacNode annotationNode) {
|
||||
if (JacksonAnnotations.JSON_IGNORE.isAnnotating(fieldNode)) {
|
||||
return;
|
||||
}
|
||||
JavacTreeMaker maker = fieldNode.getTreeMaker();
|
||||
|
||||
JCExpression jsonPropertyType = chainDots(fieldNode, JacksonAnnotations.JSON_IGNORE.chainedDots);
|
||||
|
||||
Reference in new issue
Block a user