Changed the getLatestMessage to be java 7 syntax

Voter-Registry
Vladimir Eliezer Tokarev 2016-03-12 05:50:42 -08:00
parent b4661d0fed
commit 37002a7f1e
3 changed files with 8 additions and 5 deletions

View File

@ -39,9 +39,12 @@ public class BulletinBoardUtils {
* @return BulletinBoardMessage * @return BulletinBoardMessage
*/ */
public static BulletinBoardMessage getLatestMessage(Collection<BulletinBoardMessage> messages){ public static BulletinBoardMessage getLatestMessage(Collection<BulletinBoardMessage> messages){
return Collections.max(messages, (first, second) -> { return Collections.max(messages, new Comparator<BulletinBoardMessage>() {
@Override
public int compare(BulletinBoardMessage o1, BulletinBoardMessage o2) {
TimestampComparator comparator = new TimestampComparator(); TimestampComparator comparator = new TimestampComparator();
return comparator.compare(first.getMsg().getTimestamp(), second.getMsg().getTimestamp()); return comparator.compare(o1.getMsg().getTimestamp(), o2.getMsg().getTimestamp());
}
}); });
} }

View File

@ -7,7 +7,7 @@ import java.util.Comparator;
/** /**
* Created by Arbel Deutsch Peled on 20-Feb-16. * Created by Arbel Deutsch Peled on 20-Feb-16.
*/ */
public class TimestampComparator implements Comparator<com.google.protobuf.Timestamp> { public class TimestampComparator implements Comparator<Timestamp> {
@Override @Override
public int compare(Timestamp o1, Timestamp o2) { public int compare(Timestamp o1, Timestamp o2) {

View File

@ -1,7 +1,7 @@
package meerkat.registry.AsyncRegistryCallbacks; package meerkat.registry.AsyncRegistryCallbacks;
import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.FutureCallback;
import meerkat.protobuf.BulletinBoardAPI.*; import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
import meerkat.protobuf.VoterRegistry; import meerkat.protobuf.VoterRegistry;
import meerkat.registry.RegistryTags; import meerkat.registry.RegistryTags;