package org.silverpeas.mobile.shared.dto.survey;

import static org.fusesource.restygwt.client.AbstractJsonEncoderDecoder.*;

public class QuestionDTO_Generated_JsonEncoderDecoder_ extends org.fusesource.restygwt.client.AbstractJsonEncoderDecoder<org.silverpeas.mobile.shared.dto.survey.QuestionDTO> {
  
  public static final QuestionDTO_Generated_JsonEncoderDecoder_ INSTANCE = new QuestionDTO_Generated_JsonEncoderDecoder_();
  
  public com.google.gwt.json.client.JSONValue encode(org.silverpeas.mobile.shared.dto.survey.QuestionDTO value) {
    if( value==null ) {
      return getNullType();
    }
      return encodeQuestionDTO1518325308(value);
    }
    
    private com.google.gwt.json.client.JSONValue encodeQuestionDTO1518325308( org.silverpeas.mobile.shared.dto.survey.QuestionDTO value) {
      com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
      org.silverpeas.mobile.shared.dto.survey.QuestionDTO parseValue = (org.silverpeas.mobile.shared.dto.survey.QuestionDTO)value;
      isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
      isNotNullValuePut(STRING.encode(parseValue.getType()), rc, "type");
      isNotNullValuePut(STRING.encode(parseValue.getLabel()), rc, "label");
      isNotNullValuePut(toJSON(parseValue.getAnswers(), org.silverpeas.mobile.shared.dto.survey.AnswerDTO_Generated_JsonEncoderDecoder_.INSTANCE), rc, "answers");
      isNotNullValuePut(toJSON(parseValue.getResponses(), org.silverpeas.mobile.shared.dto.survey.ResponseDTO_Generated_JsonEncoderDecoder_.INSTANCE), rc, "responses");
      return rc;
    }
    
    public org.silverpeas.mobile.shared.dto.survey.QuestionDTO decode(com.google.gwt.json.client.JSONValue value) {
      if( value == null || value.isNull()!=null ) {
        return null;
      }
      com.google.gwt.json.client.JSONObject object = toObject(value);
        return decodeQuestionDTO1518325308(object);
      }
      
      private org.silverpeas.mobile.shared.dto.survey.QuestionDTO decodeQuestionDTO1518325308(com.google.gwt.json.client.JSONObject object) {
        org.silverpeas.mobile.shared.dto.survey.QuestionDTO rc = new org.silverpeas.mobile.shared.dto.survey.QuestionDTO();
        rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
        rc.setType(getValueToSet(STRING.decode(object.get("type")), null));
        rc.setLabel(getValueToSet(STRING.decode(object.get("label")), null));
        rc.setAnswers(getValueToSet(toList(object.get("answers"), org.silverpeas.mobile.shared.dto.survey.AnswerDTO_Generated_JsonEncoderDecoder_.INSTANCE), null));
        rc.setResponses(getValueToSet(toList(object.get("responses"), org.silverpeas.mobile.shared.dto.survey.ResponseDTO_Generated_JsonEncoderDecoder_.INSTANCE), null));
        return rc;
      }
      
    }
