private static void checkQuestion(final Question pQuestion) throws CheckError { switch (pQuestion.getType()) { case SELECT: checkSelectionCountIsGeOne(pQuestion); break; case MULTI_SELECT: checkSelectionCountIsGeOne(pQuestion); break; case TEXT: checkSelectionCountIsZeroOrOne(pQuestion); break; case TEXTAREA: checkSelectionCountIsZeroOrOne(pQuestion); break; case SELECT_WITH_TEXT: checkSelectionCountIsGeOne(pQuestion); break; default: throw new IllegalStateException(); } }
private static void checkSelectionCountIsZeroOrOne(final Question pQuestion) throws CheckError { if (pQuestion.getSelections().size() > 1) { throw new CheckError( "タイプが " + pQuestion.getType() + " の設問には2つ以上の選択肢は指定出来ません."); // $NON-NLS-1$//$NON-NLS-2$ } }
private static void checkSelectionCountIsGeOne(final Question pQuestion) throws CheckError { if (pQuestion.getSelections().size() < 2) { throw new CheckError( "タイプが " + pQuestion.getType() + " の設問には少なくとも2つの選択肢が必要です."); // $NON-NLS-1$ //$NON-NLS-2$ } }