package performa.orm;

import oneit.objstore.StorageException;
import performa.orm.types.CriteriaType;


public class AssessmentCriteriaAnswer extends BaseAssessmentCriteriaAnswer
{
    private static final long serialVersionUID = 0L;
    
    // This constructor should not be called
    public AssessmentCriteriaAnswer ()
    {
        // Do not add any code to this, always put it in initialiseNewObject
    }

    
    @Override
    public boolean filterCriteriaType(CriteriaType criteriaType) throws StorageException 
    {
        return checkCriteriaTypeMatches(criteriaType);
    }

    @Override
    public boolean filterByCriteriaType(CriteriaType criteriaType) throws StorageException
    {
        return checkCriteriaTypeMatches(criteriaType);
    }
    
    private boolean checkCriteriaTypeMatches(CriteriaType criteriaType)
    {
        return (criteriaType == null ? true : (getAssessmentCriteria() != null && (getAssessmentCriteria().getCriteriaType() == criteriaType)));    //Should bypass condition if input param is null
    }
    
    //Currently we have a yes/no. We'll also have a select from (via a dropdown) in future - but still, there'll be one correct answer.
    public boolean isCorrectAnswer()
    {
        return isTrue(getAnswer());
    }
}