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

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

public class QuestionDTO_Generated_JsonEncoderDecoder_ extends org.fusesource.restygwt.client.AbstractJsonEncoderDecoder<org.silverpeas.mobile.shared.dto.faq.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.faq.QuestionDTO value) {
    if( value==null ) {
      return getNullType();
    }
      return encodeQuestionDTO1956116154(value);
    }
    
    private com.google.gwt.json.client.JSONValue encodeQuestionDTO1956116154( org.silverpeas.mobile.shared.dto.faq.QuestionDTO value) {
      com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
      org.silverpeas.mobile.shared.dto.faq.QuestionDTO parseValue = (org.silverpeas.mobile.shared.dto.faq.QuestionDTO)value;
      isNotNullValuePut(STRING.encode(parseValue.getTitle()), rc, "title");
      isNotNullValuePut(org.silverpeas.mobile.shared.dto.faq.CategoryDTO_Generated_JsonEncoderDecoder_.INSTANCE.encode(parseValue.getCategory()), rc, "category");
      isNotNullValuePut(toJSON(parseValue.getReplies(), org.silverpeas.mobile.shared.dto.faq.ReplyDTO_Generated_JsonEncoderDecoder_.INSTANCE), rc, "replies");
      return rc;
    }
    
    public org.silverpeas.mobile.shared.dto.faq.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 decodeQuestionDTO1956116154(object);
      }
      
      private org.silverpeas.mobile.shared.dto.faq.QuestionDTO decodeQuestionDTO1956116154(com.google.gwt.json.client.JSONObject object) {
        org.silverpeas.mobile.shared.dto.faq.QuestionDTO rc = new org.silverpeas.mobile.shared.dto.faq.QuestionDTO();
        rc.setTitle(getValueToSet(STRING.decode(object.get("title")), null));
        rc.setCategory(getValueToSet(org.silverpeas.mobile.shared.dto.faq.CategoryDTO_Generated_JsonEncoderDecoder_.INSTANCE.decode(object.get("category")), null));
        rc.setReplies(getValueToSet(toList(object.get("replies"), org.silverpeas.mobile.shared.dto.faq.ReplyDTO_Generated_JsonEncoderDecoder_.INSTANCE), null));
        return rc;
      }
      
    }
