java我可以指定要添加到不可变生成类中的注释吗?
我有一些使用不可变(https://immutables.github.io/)的代码,它生成了一个ImmutableEntity
类,方法如下:
public static ImmutableEntity of(EntityId id,
Locale language,
String text)) {
return validate(new EntityMeldung(id, language, text));
}
但要使用MongoDB Pojo,我需要该方法具有如下注释:
@BsonCreator
public static ImmutableEntity of(@BsonProperty("id") EntityId id,
@BsonProperty("language") Locale language,
@BsonProperty("text") String text)) {
return validate(new ImmutableEntity(id, language, text));
}
Entity
接口只定义了一些getter,我宁愿继续让Immutables生成ImmutableEntity
类和of()
之类的方法
我应该看Annotation Injection吗
共 (0) 个答案