Skip to content

Instantly share code, notes, and snippets.

@madhu314
Last active January 14, 2017 14:21
Show Gist options
  • Save madhu314/366e19f50457a3df59d4c959e17f2516 to your computer and use it in GitHub Desktop.
Save madhu314/366e19f50457a3df59d4c959e17f2516 to your computer and use it in GitHub Desktop.
Article.java
@AutoValue public abstract class Article implements Parcelable {
//.....
public static final ArticleTimestampComparator timestampComparator =
new ArticleTimestampComparator();
public static final ArticleAuthorComparator authorComparator =
new ArticleAuthorComparator();
public static final ArticleContentComparator contentComparator =
new ArticleContentComparator();
public static final ArticleCategoryComparator categoryComparator =
new ArticleCategoryComparator();
public int compare(Article article, Comparator<Article> articleComparator) {
return articleComparator.compare(this, article);
}
public int compare(Article article) {
return timestampComparator.compare(this, article);
}
public boolean areContentsTheSame(Article article) {
return this.equals(article);
}
public boolean areItemsTheSame(Article article) {
return this.id() == article.id();
}
//......
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment