mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 06:17:44 +00:00
@Jacksonized: add flag usage configuration key
This commit is contained in:
1 parent
8be4b0ffe6
commit
a749bc230f
4 files changed
+20
-5
No files matched your search
@@ -651,6 +651,15 @@ public class ConfigurationKeys {
|
||||
* If set, <em>any</em> usage of {@code @WithBy} results in a warning / error.
|
||||
*/
|
||||
public static final ConfigurationKey<FlagUsageType> WITHBY_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.withBy.flagUsage", "Emit a warning or error if @WithBy is used.") {};
|
||||
|
||||
// ----- Jacksonized -----
|
||||
|
||||
/**
|
||||
* lombok configuration: {@code lombok.jacksonized.flagUsage} = {@code WARNING} | {@code ERROR}.
|
||||
*
|
||||
* If set, <em>any</em> usage of {@code @Jacksonized} results in a warning / error.
|
||||
*/
|
||||
public static final ConfigurationKey<FlagUsageType> JACKSONIZED_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.jacksonized.flagUsage", "Emit a warning or error if @Jacksonized is used.") {};
|
||||
|
||||
// ----- Configuration System -----
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package lombok.eclipse.handlers;
|
||||
|
||||
import static lombok.core.handlers.HandlerUtil.handleExperimentalFlagUsage;
|
||||
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -62,6 +63,8 @@ public class HandleJacksonized extends EclipseAnnotationHandler<Jacksonized> {
|
||||
private static final char[][] JSON_DESERIALIZE_ANNOTATION = Eclipse.fromQualifiedName("com.fasterxml.jackson.databind.annotation.JsonDeserialize");
|
||||
|
||||
@Override public void handle(AnnotationValues<Jacksonized> annotation, Annotation ast, EclipseNode annotationNode) {
|
||||
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.JACKSONIZED_FLAG_USAGE, "@Jacksonized");
|
||||
|
||||
EclipseNode annotatedNode = annotationNode.up();
|
||||
|
||||
EclipseNode tdNode;
|
||||
|
||||
+5
-5
@@ -41,20 +41,20 @@ import lombok.experimental.SuperBuilder;
|
||||
* In particular, the annotation does the following:
|
||||
* <ul>
|
||||
* <li>Configure Jackson to use the builder for deserialization using
|
||||
* {@code @JsonDeserialize(builder=MyClass.MyClassBuilder[Impl].class))} on the
|
||||
* class. (An error is emitted if such an annotation already exists.)
|
||||
* {@code @JsonDeserialize(builder=Foobar.FoobarBuilder[Impl].class)}
|
||||
* on the class (where <em>Foobar</em> is the name of the annotated class).</li>
|
||||
* <li>Copy Jackson-related configuration annotations (like
|
||||
* {@code @JsonIgnoreProperties}) from the class to the builder class. This is
|
||||
* necessary so that Jackson recognizes them when using the builder.
|
||||
* necessary so that Jackson recognizes them when using the builder.</li>
|
||||
* <li>Insert {@code @JsonPOJOBuilder(withPrefix="")} on the generated builder
|
||||
* class to override Jackson's default prefix "with". If you configured a
|
||||
* different prefix in lombok using {@code setterPrefix}, this value is used. If
|
||||
* you changed the name of the {@code build()} method using using
|
||||
* {@code buildMethodName}, this is also made known to Jackson.
|
||||
* {@code buildMethodName}, this is also made known to Jackson.</li>
|
||||
* <li>For {@code @SuperBuilder}, make the builder implementation class
|
||||
* package-private.</li>
|
||||
* </ul>
|
||||
* This annotation does <i>not</i> change the behavior of the generated builder.
|
||||
* This annotation does <em>not</em> change the behavior of the generated builder.
|
||||
* A {@code @Jacksonized} {@code @SuperBuilder} remains fully compatible to
|
||||
* regular {@code @SuperBuilder}s.
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package lombok.javac.handlers;
|
||||
|
||||
import static lombok.core.handlers.HandlerUtil.handleExperimentalFlagUsage;
|
||||
import static lombok.javac.handlers.JavacHandlerUtil.*;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
@@ -59,6 +60,8 @@ import lombok.javac.JavacTreeMaker;
|
||||
public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
|
||||
|
||||
@Override public void handle(AnnotationValues<Jacksonized> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.JACKSONIZED_FLAG_USAGE, "@Jacksonized");
|
||||
|
||||
JavacNode annotatedNode = annotationNode.up();
|
||||
deleteAnnotationIfNeccessary(annotationNode, Jacksonized.class);
|
||||
|
||||
|
||||
Reference in new issue
Block a user