我想将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.
更多推荐
发布评论