gpt4 book ai didi

java - lombok key 已经注册

转载 作者:行者123 更新时间:2023-11-30 11:05:34 24 4
gpt4 key购买 nike

我收到 IllegalArgumentException key 已经在自定义 lombok 处理程序上注册。

@ProviderFor(EclipseAnnotationHandler.class)
public class HandleEntityData extends EclipseAnnotationHandler<EntityData> {

@Override
public void handle(AnnotationValues<EntityData> annotation,
Annotation ast,
EclipseNode annotationNode) {

handleFlagUsage(
annotationNode,
new ConfigurationKey<FlagUsageType>("lombok.entity.flagUsage",
"Emit a warning or error if @EntityData is used.") {},
"@EntityData"
);


}

我已经检查过 key 是唯一的。所以想知道是否有人知道为什么?

最佳答案

找到了我自己问题的答案。基本上将 CONFIGURATION 键作为一个单独的静态常量移动,这样它就不会在每次调用 handle() 时都被构造。 (关键对象的身份似乎回退到 Object equals/hashcode。)

@ProviderFor(EclipseAnnotationHandler.class)
public class HandleEntityData extends EclipseAnnotationHandler<EntityData> {

public final static ConfigurationKey CONFIGURATION_KEY = new ConfigurationKey<FlagUsageType>("lombok.entity.flagUsage",
"Emit a warning or error if @EntityData is used.") {};

@Override
public void handle(AnnotationValues<EntityData> annotation,
Annotation ast,
EclipseNode annotationNode) {

handleFlagUsage(
annotationNode,
CONFIGURATION_KEYS,
"@EntityData"
);


}

关于java - lombok key 已经注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29612834/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com