StudentQuestionAnswerComparator.java

package edu.rit.coopeval.comparators;

import edu.rit.coopeval.model.StudentQuestionAnswer;

import java.util.Comparator;

/**
 * Created by mhickson on 2/26/15.
 */
public class StudentQuestionAnswerComparator implements Comparator<StudentQuestionAnswer> {
    @Override
    public int compare(StudentQuestionAnswer studentQuestionAnswer1, StudentQuestionAnswer studentQuestionAnswer2){
        Long order1 = studentQuestionAnswer1.getFormQuestionByFormQuestionId().getQuestionOrder();
        Long order2 = studentQuestionAnswer2.getFormQuestionByFormQuestionId().getQuestionOrder();
        if(order1>order2){
            return 1;
        }
        else if(order1<order2){
            return -1;
        }
        else{
            return 0;
        }
    }
}