使用Google AutoValue客观化(Objectify with Google AutoValue)

编程入门 行业动态 更新时间:2024-10-25 09:39:49
使用Google AutoValue客观化(Objectify with Google AutoValue)

我想将objectify模型实体用于自动值。 Objectify需要带字段值的@Id注释,但在Google AutoValue中,所有字段都需要转换为抽象方法,因此我无法将@Id应用于抽象方法。 你有什么建议?

@Entity @Cache @AutoValue public abstract class AccountDetail { // Objectify needs this @Id private long id; // auto value needs this abstract long id(); }

I want to use auto value with objectify model entity. Objectify requires @Id annotation with a field value however in Google AutoValue all fields need to be converted to abstract methods, so I can't apply @Id to a abstract method. What is your suggestions?

@Entity @Cache @AutoValue public abstract class AccountDetail { // Objectify needs this @Id private long id; // auto value needs this abstract long id(); }

最满意答案

我不熟悉AutoValue,但看起来不太可能。 Objectify适用于真实课程的真实领域。 您需要某种方法来强制该工具生成带有相关注释的代码。

你考虑过lombok吗? 这是一种避免大量Java样板并且不需要代码生成的优雅方法。

I'm not familiar with AutoValue, but it doesn't look possible. Objectify works with real fields on real classes. You'd need some way of forcing the tool to generate code with the relevant annotations.

Have you considered lombok? It is an elegant way of avoiding a lot of Java's boilerplate and doesn't require code generation.

更多推荐

本文发布于:2023-07-29 18:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1318617.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客观化   Google   AutoValue   Objectify

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!