Skip to content

Commit 290fa4c

Browse files
committed
[trivial] constantize the warning we spit out for ambiguous jackson2/3, and match style to lombok project style.
1 parent e6567b6 commit 290fa4c

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/core/lombok/core/configuration/JacksonVersion.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public enum JacksonVersion implements MappedConfigEnum {
2626
THREE,
2727
;
2828

29+
public static final String AMBIGUOUS_JACKSON_VERSION_WARNING_TEXT =
30+
"Ambiguous: Jackson2 and Jackson3 exist; define which variant(s) you want in 'lombok.config'. See https://projectlombok.org/features/experimental/Jacksonized";
31+
2932
@Override public boolean matches(String value) {
3033
if (this == TWO) return "2".equals(value);
3134
return "3".equals(value);

src/core/lombok/eclipse/handlers/HandleJacksonized.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private void handleJacksonizedAccessors(Annotation ast, EclipseNode annotationNo
188188
// Add @JsonProperty to all fields. It will be automatically copied to the getter/setters later.
189189
for (EclipseNode eclipseNode : tdNode.down()) {
190190
if (eclipseNode.getKind() == Kind.FIELD) {
191-
if (hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_PROPERTY2) ||
191+
if (hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_PROPERTY2) ||
192192
hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_IGNORE2)) {
193193
continue;
194194
}
@@ -210,15 +210,15 @@ private void createJsonPropertyForField(EclipseNode fieldNode, EclipseNode annot
210210
fd.annotations = addAnnotation(fieldNode.get(), fd.annotations, JacksonAnnotationType.JSON_PROPERTY2.getQualifiednameAsCharArrayArray(), fieldName);
211211
}
212212
}
213-
213+
214214
private void createJsonIgnoreForField(EclipseNode fieldNode, EclipseNode annotationNode) {
215215
ASTNode astNode = fieldNode.get();
216216
if (astNode instanceof FieldDeclaration) {
217217
FieldDeclaration fd = (FieldDeclaration) astNode;
218218
fd.annotations = addAnnotation(fieldNode.get(), fd.annotations, JacksonAnnotationType.JSON_IGNORE2.getQualifiednameAsCharArrayArray());
219219
}
220220
}
221-
221+
222222
private String getBuilderClassName(Annotation ast, EclipseNode annotationNode, EclipseNode annotatedNode, TypeDeclaration td, AnnotationValues<Builder> builderAnnotation) {
223223
String builderClassName = builderAnnotation != null ?
224224
builderAnnotation.getInstance().builderClassName() : null;
@@ -246,7 +246,7 @@ private String getBuilderClassName(Annotation ast, EclipseNode annotationNode, E
246246
private List<JacksonVersion> readConfiguredJacksonVersions(EclipseNode annotationNode) {
247247
List<JacksonVersion> jacksonVersions = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, Arrays.<JacksonVersion>asList());
248248
if (!jacksonVersions.isEmpty()) return jacksonVersions;
249-
annotationNode.addWarning("Ambiguous: Jackson2 and Jackson3 exist; define which variant(s) you want in 'lombok.config'. See https://projectlombok.org/features/experimental/Jacksonized");
249+
annotationNode.addWarning(JacksonVersion.AMBIGUOUS_JACKSON_VERSION_WARNING_TEXT);
250250
return Arrays.asList(JacksonVersion.TWO);
251251
}
252252

src/core/lombok/javac/handlers/HandleJacksonized.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ private void createJsonPropertyForField(JavacNode fieldNode, JavacNode annotatio
135135
List<JCExpression> args = List.<JCExpression>of(maker.Literal(fieldNode.getName()));
136136
addFieldAnnotation(fieldNode, annotationNode, JacksonAnnotationType.JSON_PROPERTY2, args);
137137
}
138-
138+
139139
private void createJsonIgnoreForField(JavacNode fieldNode, JavacNode annotationNode) {
140140
addFieldAnnotation(fieldNode, annotationNode, JacksonAnnotationType.JSON_IGNORE2, List.<JCExpression>nil());
141141
}
142-
142+
143143
private void addFieldAnnotation(JavacNode fieldNode, JavacNode annotationNode, JacksonAnnotationType annotationType, List<JCExpression> args) {
144144
JavacTreeMaker maker = fieldNode.getTreeMaker();
145145
JCExpression type = chainDots(fieldNode, annotationType);
@@ -192,7 +192,7 @@ private void handleJacksonizedBuilder(JavacNode annotationNode, JavacNode annota
192192
}
193193

194194
Collection<JacksonVersion> jacksonVersions = readConfiguredJacksonVersions(annotationNode);
195-
195+
196196
// Insert @JsonDeserialize on annotated class.
197197
if (hasAnnotation(tdNode, JacksonAnnotationType.JSON_DESERIALIZE2) || hasAnnotation(tdNode, JacksonAnnotationType.JSON_DESERIALIZE3)) {
198198
annotationNode.addError("@JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson.");
@@ -278,7 +278,7 @@ private String getBuilderClassName(JavacNode annotationNode, JavacNode annotated
278278
private Collection<JacksonVersion> readConfiguredJacksonVersions(JavacNode annotationNode) {
279279
Collection<JacksonVersion> jacksonVersions = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, Arrays.<JacksonVersion>asList());
280280
if (!jacksonVersions.isEmpty()) return jacksonVersions;
281-
annotationNode.addWarning("Ambiguous: Jackson2 and Jackson3 exist; define which variant(s) you want in 'lombok.config'. See https://projectlombok.org/features/experimental/Jacksonized");
281+
annotationNode.addWarning(JacksonVersion.AMBIGUOUS_JACKSON_VERSION_WARNING_TEXT);
282282
return Arrays.asList(JacksonVersion.TWO);
283283
}
284284

0 commit comments

Comments
 (0)