/*
 * Copyright 2015 Dmitry Ustalov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package mtsar.api.validation;

import io.dropwizard.validation.ValidationMethod;
import mtsar.api.Answer;
import mtsar.api.Task;

public class TaskAnswerValidation {
    private final Task task;
    private final Answer answer;

    public TaskAnswerValidation(Task task, Answer answer) {
        this.task = task;
        this.answer = answer;
    }

    @ValidationMethod(message = "#task-single-no-answer: task type 'single' requires one answer")
    public boolean isAnswerPresentForTypeSingle() {
        return !task.getType().equalsIgnoreCase("single") || answer.getAnswers().size() == 1;
    }
}

@@ -722,16 +722,68 @@
 .Task;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 public c
@@ -996,16 +996,318 @@
 %0A    %7D%0A%0A
+    @ValidationMethod(message = %22#answer-not-in-task: task has no such an answer in possible ones%22)%0A    public boolean isAnswerInDomain() %7B%0A        final List%3CString%3E answers = new ArrayList%3C%3E(answer.getAnswers());%0A        answers.removeAll(task.getAnswers());%0A        return answers.isEmpty();%0A    %7D%0A%0A
     @Val

Add isAnswerInDomain validation method [ci skip]