Last active
January 14, 2017 14:21
-
-
Save madhu314/366e19f50457a3df59d4c959e17f2516 to your computer and use it in GitHub Desktop.
Article.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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