Skip to content

Conversation

@eincs
Copy link
Contributor

@eincs eincs commented Oct 9, 2015

I'm currently creating annotation processor project for Objectify.
With this project, many convenient class source codes for Objectify will automatically generated by annotation processor.

One of generated class will be key class for specific entity.
To to this, modifier of constructors of Key class should be modified to at least protected.

Let me give example about key class for specific entity:

@Entity
public class Article {
    @Id
     private long id;
     ...
}

Will generate specific key class like:

public ArticleKey extends Key<Article> {
    ...
}

I think this kind of specific key class makes easier to use Objectify library.

// original
Key<Article> articleKey = Key.create(Article.class, articleId);
Key<Comment> commentKey = Key.create(articleKey, Comment.class, commentId)

// with objectify-apt library
ArticleKey articleKey = ArticleKey.newKey(articleId); 
CommentKey commentKey = articleKey.newCommentKey(commentId);
LoadResult<Comment> key = ofy().load().key(commentKey);

There are several benefits such as...

  • Shorter code.
  • Easier auto-completion for creating key class.
  • Parent-Child relationship between Entity can be strictly on compile time
  • And so on...

So, please accept this pull-request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant