// First we assume all old entries needs to be deleted and then we figure out the ones to keep
Map toDeleteEntries = FluentIterable.from( knownEntries )
.uniqueIndex( new Function()
{
@Override
public String apply( StreamEntry entry )
{
CalendarStreamRawData rawCalendar = (CalendarStreamRawData) entry.getRawdata();
return rawCalendar.getItemSourceType() + "::" + rawCalendar.getItemSourceId().toString();
}
} );
.................................
// Fill toDelete list, basically all items that are not in toKeep list will be deleted
Collection toDelete = FluentIterable.from( toDeleteEntries.values() )
.transform( new Function()
{
@Override
public Long apply( StreamEntry entry )
{
return entry.getSequenceID();
}
} ).toList();
阅读(1614) | 评论(0) | 转发(0) |