package net.sourceforge.fenixedu.domain.tests.predicates; import java.util.HashMap; import net.sourceforge.fenixedu.domain.DomainReference; import net.sourceforge.fenixedu.domain.Person; import net.sourceforge.fenixedu.domain.tests.NewAtomicQuestion; import net.sourceforge.fenixedu.domain.tests.NewQuestion; import net.sourceforge.fenixedu.presentationTier.Action.teacher.tests.PredicateBean; public class AnsweredQuestionPredicate extends AtomicPredicate implements Predicate { private final DomainReference atomicQuestion; public AnsweredQuestionPredicate(NewAtomicQuestion atomicQuestion) { super(); this.atomicQuestion = new DomainReference(atomicQuestion); } public AnsweredQuestionPredicate(PredicateBean predicateBean) { this(predicateBean.getAtomicQuestion()); } public boolean evaluate(NewQuestion question, Person person) { return this.getAtomicQuestion().isAnswered(person); } public NewAtomicQuestion getAtomicQuestion() { return atomicQuestion.getObject(); } public boolean uses(Object object) { NewAtomicQuestion atomicQuestion = (NewAtomicQuestion) object; return atomicQuestion.equals(this.getAtomicQuestion()); } public Predicate transform(HashMap transformMap) { NewAtomicQuestion transformation = (NewAtomicQuestion) transformMap.get(getAtomicQuestion()); return new AnsweredQuestionPredicate(transformation != null ? transformation : getAtomicQuestion()); } }