龙目岛@SuperBuilder带有json注释的示例
有人可以给我一个关于龙目岛@SuperBuilder实验注释的工作示例吗?
我无法让它运行,并且没有可用的代码示例作为文档。
目前我的代码如下所示:
超类:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = SubA.class),
@JsonSubTypes.Type(value = AnotherSub.class)
})
@Getter
@Accessors(fluent = true, chain = true)
@SuperBuilder
public abstract class AbstractA {
@JsonProperty
protected final String superProperty;
}
子类:
@Getter
@EqualsAndHashCode(callSuper = true)
@Accessors(fluent = true, chain = true)
@SuperBuilder
@JsonDeserialize(builder = SubA.SubABuilder.class) // class not found?
@JsonTypeName("SubA")
public class SubA extends AbstractA {
@JsonProperty
private final String fieldA;
}
谢谢