package meerkat.util;

import com.google.protobuf.Timestamp;

import java.util.Comparator;

/**
 * Created by Arbel Deutsch Peled on 20-Feb-16.
 */
public class TimestampComparator implements Comparator<com.google.protobuf.Timestamp> {

    @Override
    public int compare(Timestamp o1, Timestamp o2) {

        if (o1.getSeconds() != o2.getSeconds()){

            return o1.getSeconds() > o2.getSeconds() ? 2 : -2;

        } else if (o1.getNanos() != o2.getNanos()){

            return o1.getNanos() > o2.getNanos() ? 1 : -1;

        } else{

            return 0;

        }

    }

}
