mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
rewrite using lambdas
This commit is contained in:
@@ -13,7 +13,6 @@ import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.FeedSubscription;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.rometools.opml.feed.opml.Attribute;
|
||||
@@ -24,13 +23,7 @@ import com.rometools.opml.feed.opml.Outline;
|
||||
@Singleton
|
||||
public class OPMLExporter {
|
||||
|
||||
private static Long ROOT_CATEGORY_ID = new Long(-1);
|
||||
private static final Function<FeedSubscription, Long> SUBSCRIPTION_TO_CATEGORYID = new Function<FeedSubscription, Long>() {
|
||||
@Override
|
||||
public Long apply(FeedSubscription sub) {
|
||||
return sub.getCategory() == null ? ROOT_CATEGORY_ID : sub.getCategory().getId();
|
||||
}
|
||||
};
|
||||
private static Long ROOT_CATEGORY_ID = Long.valueOf(Long.MIN_VALUE);
|
||||
|
||||
private final FeedCategoryDAO feedCategoryDAO;
|
||||
private final FeedSubscriptionDAO feedSubscriptionDAO;
|
||||
@@ -42,7 +35,8 @@ public class OPMLExporter {
|
||||
opml.setCreated(new Date());
|
||||
|
||||
List<FeedCategory> categories = feedCategoryDAO.findAll(user);
|
||||
Multimap<Long, FeedSubscription> subscriptions = Multimaps.index(feedSubscriptionDAO.findAll(user), SUBSCRIPTION_TO_CATEGORYID);
|
||||
Multimap<Long, FeedSubscription> subscriptions = Multimaps.index(feedSubscriptionDAO.findAll(user),
|
||||
sub -> sub.getCategory() == null ? ROOT_CATEGORY_ID : sub.getCategory().getId());
|
||||
|
||||
// export root categories
|
||||
for (FeedCategory cat : categories) {
|
||||
|
||||
Reference in New Issue
Block a user