EmployerQuestionAnswerComparator.java

package edu.rit.coopeval.comparators;

import edu.rit.coopeval.model.EmployerQuestionAnswer;

import java.util.Comparator;

/**
 * Created by mhickson on 2/26/15.
 */
public class EmployerQuestionAnswerComparator implements Comparator<EmployerQuestionAnswer> {
    @Override
    public int compare(EmployerQuestionAnswer studentQuestionAnswer1, EmployerQuestionAnswer 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;
        }
    }
}