package net.sourceforge.fenixedu.util.tests; import java.util.Arrays; import com.linkare.commons.metainfo.Linkare; public class ResponseLID extends Response { private String[] response; private Boolean[] isCorrect = null; public ResponseLID() { super(); } public ResponseLID(String[] op) { super(); setResponse(op); } public String[] getResponse() { return response; } @Linkare(author = "Paulo Zenida", comments = "Implemented defensive copy to prevent the violation of a best practice") public void setResponse(final String[] op) { response = op == null ? null : Arrays.copyOf(op, op.length); if (op != null) { super.setResponsed(); if (op.length == 1 && op[0] == null) { response = new String[0]; } } } public Boolean[] getIsCorrect() { return isCorrect; } public void setIsCorrect(final Boolean[] isCorrect) { this.isCorrect = isCorrect == null ? null : Arrays.copyOf(isCorrect, isCorrect.length); } public boolean hasResponse(String responseOption) { if (isResponsed()) { for (int i = 0; i < response.length; i++) { if (response[i].equalsIgnoreCase(responseOption)) { return true; } } } return false; } }