mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-11 03:13:38 +00:00
[trivial] constantize the warning we spit out for ambiguous jackson2/3, and match style to lombok project style.
This commit is contained in:
3 files changed
+11
-8
No files matched your search
@@ -26,6 +26,9 @@ public enum JacksonVersion implements MappedConfigEnum {
|
||||
THREE,
|
||||
;
|
||||
|
||||
public static final String AMBIGUOUS_JACKSON_VERSION_WARNING_TEXT =
|
||||
"Ambiguous: Jackson2 and Jackson3 exist; define which variant(s) you want in 'lombok.config'. See https://projectlombok.org/features/experimental/Jacksonized";
|
||||
|
||||
@Override public boolean matches(String value) {
|
||||
if (this == TWO) return "2".equals(value);
|
||||
return "3".equals(value);
|
||||
|
||||
@@ -188,7 +188,7 @@ 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 (hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_PROPERTY2) ||
|
||||
if (hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_PROPERTY2) ||
|
||||
hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_IGNORE2)) {
|
||||
continue;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class HandleJacksonized extends EclipseAnnotationHandler<Jacksonized> {
|
||||
fd.annotations = addAnnotation(fieldNode.get(), fd.annotations, JacksonAnnotationType.JSON_PROPERTY2.getQualifiednameAsCharArrayArray(), fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createJsonIgnoreForField(EclipseNode fieldNode, EclipseNode annotationNode) {
|
||||
ASTNode astNode = fieldNode.get();
|
||||
if (astNode instanceof FieldDeclaration) {
|
||||
@@ -218,7 +218,7 @@ public class HandleJacksonized extends EclipseAnnotationHandler<Jacksonized> {
|
||||
fd.annotations = addAnnotation(fieldNode.get(), fd.annotations, JacksonAnnotationType.JSON_IGNORE2.getQualifiednameAsCharArrayArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getBuilderClassName(Annotation ast, EclipseNode annotationNode, EclipseNode annotatedNode, TypeDeclaration td, AnnotationValues<Builder> builderAnnotation) {
|
||||
String builderClassName = builderAnnotation != null ?
|
||||
builderAnnotation.getInstance().builderClassName() : null;
|
||||
@@ -246,7 +246,7 @@ public class HandleJacksonized extends EclipseAnnotationHandler<Jacksonized> {
|
||||
private List<JacksonVersion> readConfiguredJacksonVersions(EclipseNode annotationNode) {
|
||||
List<JacksonVersion> jacksonVersions = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, Arrays.<JacksonVersion>asList());
|
||||
if (!jacksonVersions.isEmpty()) return jacksonVersions;
|
||||
annotationNode.addWarning("Ambiguous: Jackson2 and Jackson3 exist; define which variant(s) you want in 'lombok.config'. See https://projectlombok.org/features/experimental/Jacksonized");
|
||||
annotationNode.addWarning(JacksonVersion.AMBIGUOUS_JACKSON_VERSION_WARNING_TEXT);
|
||||
return Arrays.asList(JacksonVersion.TWO);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,11 +135,11 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
|
||||
List<JCExpression> args = List.<JCExpression>of(maker.Literal(fieldNode.getName()));
|
||||
addFieldAnnotation(fieldNode, annotationNode, JacksonAnnotationType.JSON_PROPERTY2, args);
|
||||
}
|
||||
|
||||
|
||||
private void createJsonIgnoreForField(JavacNode fieldNode, JavacNode annotationNode) {
|
||||
addFieldAnnotation(fieldNode, annotationNode, JacksonAnnotationType.JSON_IGNORE2, List.<JCExpression>nil());
|
||||
}
|
||||
|
||||
|
||||
private void addFieldAnnotation(JavacNode fieldNode, JavacNode annotationNode, JacksonAnnotationType annotationType, List<JCExpression> args) {
|
||||
JavacTreeMaker maker = fieldNode.getTreeMaker();
|
||||
JCExpression type = chainDots(fieldNode, annotationType);
|
||||
@@ -192,7 +192,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
|
||||
}
|
||||
|
||||
Collection<JacksonVersion> jacksonVersions = readConfiguredJacksonVersions(annotationNode);
|
||||
|
||||
|
||||
// Insert @JsonDeserialize on annotated class.
|
||||
if (hasAnnotation(tdNode, JacksonAnnotationType.JSON_DESERIALIZE2) || hasAnnotation(tdNode, JacksonAnnotationType.JSON_DESERIALIZE3)) {
|
||||
annotationNode.addError("@JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson.");
|
||||
@@ -278,7 +278,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
|
||||
private Collection<JacksonVersion> readConfiguredJacksonVersions(JavacNode annotationNode) {
|
||||
Collection<JacksonVersion> jacksonVersions = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, Arrays.<JacksonVersion>asList());
|
||||
if (!jacksonVersions.isEmpty()) return jacksonVersions;
|
||||
annotationNode.addWarning("Ambiguous: Jackson2 and Jackson3 exist; define which variant(s) you want in 'lombok.config'. See https://projectlombok.org/features/experimental/Jacksonized");
|
||||
annotationNode.addWarning(JacksonVersion.AMBIGUOUS_JACKSON_VERSION_WARNING_TEXT);
|
||||
return Arrays.asList(JacksonVersion.TWO);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user