mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-11 03:13:38 +00:00
Introduce JacksonVersion.getDefault()
This commit is contained in:
1 parent
3dd5ad38da
commit
1427fecfbb
3 files changed
+13
-9
No files matched your search
@@ -5,13 +5,12 @@ public final class JacksonVersion implements ConfigurationValueType {
|
||||
private final boolean useJackson2;
|
||||
private final boolean useJackson3;
|
||||
|
||||
public static final JacksonVersion _2 = new JacksonVersion(true, false);
|
||||
public static final JacksonVersion _3 = new JacksonVersion(false, true);
|
||||
public static final JacksonVersion _23 = new JacksonVersion(true, true);
|
||||
private static final JacksonVersion _2 = new JacksonVersion(true, false);
|
||||
private static final JacksonVersion _3 = new JacksonVersion(false, true);
|
||||
private static final JacksonVersion _23 = new JacksonVersion(true, true);
|
||||
|
||||
public JacksonVersion(boolean useJackson2, boolean useJackson3) {
|
||||
this.useJackson2 = useJackson2;
|
||||
this.useJackson3 = useJackson3;
|
||||
public static final JacksonVersion getDefault() {
|
||||
return _2;
|
||||
}
|
||||
|
||||
public static String exampleValue() {
|
||||
@@ -24,7 +23,7 @@ public final class JacksonVersion implements ConfigurationValueType {
|
||||
|
||||
public static JacksonVersion valueOf(String value) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
return _2;
|
||||
return getDefault();
|
||||
} else if ("2".equals(value.trim())) {
|
||||
return _2;
|
||||
} else if ("3".equals(value.trim())) {
|
||||
@@ -36,6 +35,11 @@ public final class JacksonVersion implements ConfigurationValueType {
|
||||
}
|
||||
}
|
||||
|
||||
private JacksonVersion(boolean useJackson2, boolean useJackson3) {
|
||||
this.useJackson2 = useJackson2;
|
||||
this.useJackson3 = useJackson3;
|
||||
}
|
||||
|
||||
public boolean useJackson2() {
|
||||
return useJackson2;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class HandleJacksonized extends EclipseAnnotationHandler<Jacksonized> {
|
||||
ClassLiteralAccess builderClassLiteralAccess = new ClassLiteralAccess(td.sourceEnd, builderClassExpression);
|
||||
MemberValuePair builderMvp = new MemberValuePair("builder".toCharArray(), td.sourceStart, td.sourceEnd, builderClassLiteralAccess);
|
||||
|
||||
JacksonVersion jacksonVersion = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, JacksonVersion._2);
|
||||
JacksonVersion jacksonVersion = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, JacksonVersion.getDefault());
|
||||
if (jacksonVersion == null || !jacksonVersion.isValid()) {
|
||||
annotationNode.addError("No valid jackson version selected.");
|
||||
return;
|
||||
|
||||
@@ -174,7 +174,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
|
||||
return;
|
||||
}
|
||||
|
||||
JacksonVersion jacksonVersion = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, JacksonVersion._2);
|
||||
JacksonVersion jacksonVersion = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, JacksonVersion.getDefault());
|
||||
if (jacksonVersion == null || !jacksonVersion.isValid()) {
|
||||
annotationNode.addError("No valid jackson version selected.");
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user