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

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

public class SurveyDetailDTO_Generated_JsonEncoderDecoder_ extends org.fusesource.restygwt.client.AbstractJsonEncoderDecoder<org.silverpeas.mobile.shared.dto.survey.SurveyDetailDTO> {
  
  public static final SurveyDetailDTO_Generated_JsonEncoderDecoder_ INSTANCE = new SurveyDetailDTO_Generated_JsonEncoderDecoder_();
  
  public com.google.gwt.json.client.JSONValue encode(org.silverpeas.mobile.shared.dto.survey.SurveyDetailDTO value) {
    if( value==null ) {
      return getNullType();
    }
      return encodeSurveyDetailDTO1974647325(value);
    }
    
    private com.google.gwt.json.client.JSONValue encodeSurveyDetailDTO1974647325( org.silverpeas.mobile.shared.dto.survey.SurveyDetailDTO value) {
      com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
      org.silverpeas.mobile.shared.dto.survey.SurveyDetailDTO parseValue = (org.silverpeas.mobile.shared.dto.survey.SurveyDetailDTO)value;
      isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
      isNotNullValuePut(toJSON(parseValue.getQuestions(), org.silverpeas.mobile.shared.dto.survey.QuestionDTO_Generated_JsonEncoderDecoder_.INSTANCE), rc, "questions");
      isNotNullValuePut(STRING.encode(parseValue.getComments()), rc, "comments");
      isNotNullValuePut(BOOLEAN.encode(parseValue.isAnonymComment()), rc, "anonymComment");
      isNotNullValuePut(BOOLEAN.encode(parseValue.isCanParticipate()), rc, "canParticipate");
      isNotNullValuePut(INT.encode(parseValue.getNbParticipation()), rc, "nbParticipation");
      return rc;
    }
    
    public org.silverpeas.mobile.shared.dto.survey.SurveyDetailDTO 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 decodeSurveyDetailDTO1974647325(object);
      }
      
      private org.silverpeas.mobile.shared.dto.survey.SurveyDetailDTO decodeSurveyDetailDTO1974647325(com.google.gwt.json.client.JSONObject object) {
        org.silverpeas.mobile.shared.dto.survey.SurveyDetailDTO rc = new org.silverpeas.mobile.shared.dto.survey.SurveyDetailDTO();
        rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
        rc.setQuestions(getValueToSet(toList(object.get("questions"), org.silverpeas.mobile.shared.dto.survey.QuestionDTO_Generated_JsonEncoderDecoder_.INSTANCE), null));
        rc.setComments(getValueToSet(STRING.decode(object.get("comments")), null));
        rc.setAnonymComment(getValueToSet(BOOLEAN.decode(object.get("anonymComment")), false));
        rc.setCanParticipate(getValueToSet(BOOLEAN.decode(object.get("canParticipate")), false));
        rc.setNbParticipation(getValueToSet(INT.decode(object.get("nbParticipation")), 0));
        return rc;
      }
      
    }
