package org.silverpeas.mobile.shared.dto;

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

public class FormFieldDTO_Generated_JsonEncoderDecoder_ extends org.fusesource.restygwt.client.AbstractJsonEncoderDecoder<org.silverpeas.mobile.shared.dto.FormFieldDTO> {
  
  public static final FormFieldDTO_Generated_JsonEncoderDecoder_ INSTANCE = new FormFieldDTO_Generated_JsonEncoderDecoder_();
  
  public com.google.gwt.json.client.JSONValue encode(org.silverpeas.mobile.shared.dto.FormFieldDTO value) {
    if( value==null ) {
      return getNullType();
    }
      return encodeFormFieldDTO238951885(value);
    }
    
    private com.google.gwt.json.client.JSONValue encodeFormFieldDTO238951885( org.silverpeas.mobile.shared.dto.FormFieldDTO value) {
      com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
      org.silverpeas.mobile.shared.dto.FormFieldDTO parseValue = (org.silverpeas.mobile.shared.dto.FormFieldDTO)value;
      isNotNullValuePut(BOOLEAN.encode(parseValue.isReadOnly()), rc, "readOnly");
      isNotNullValuePut(BOOLEAN.encode(parseValue.isMandatory()), rc, "mandatory");
      isNotNullValuePut(STRING.encode(parseValue.getDisplayerName()), rc, "displayerName");
      isNotNullValuePut(STRING.encode(parseValue.getName()), rc, "name");
      isNotNullValuePut(STRING.encode(parseValue.getLabel()), rc, "label");
      isNotNullValuePut(STRING.encode(parseValue.getValue()), rc, "value");
      isNotNullValuePut(STRING.encode(parseValue.getValueId()), rc, "valueId");
      isNotNullValuePut(STRING.encode(parseValue.getType()), rc, "type");
      isNotNullValuePut(toJSON(parseValue.getValues(), STRING, STRING, org.fusesource.restygwt.client.Json.Style.DEFAULT), rc, "values");
      isNotNullValuePut(STRING.encode(parseValue.getInstanceId()), rc, "instanceId");
      isNotNullValuePut(STRING.encode(parseValue.getId()), rc, "id");
      return rc;
    }
    
    public org.silverpeas.mobile.shared.dto.FormFieldDTO 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 decodeFormFieldDTO238951885(object);
      }
      
      private org.silverpeas.mobile.shared.dto.FormFieldDTO decodeFormFieldDTO238951885(com.google.gwt.json.client.JSONObject object) {
        org.silverpeas.mobile.shared.dto.FormFieldDTO rc = new org.silverpeas.mobile.shared.dto.FormFieldDTO();
        rc.setReadOnly(getValueToSet(BOOLEAN.decode(object.get("readOnly")), false));
        rc.setMandatory(getValueToSet(BOOLEAN.decode(object.get("mandatory")), false));
        rc.setDisplayerName(getValueToSet(STRING.decode(object.get("displayerName")), null));
        rc.setName(getValueToSet(STRING.decode(object.get("name")), null));
        rc.setLabel(getValueToSet(STRING.decode(object.get("label")), null));
        rc.setValue(getValueToSet(STRING.decode(object.get("value")), null));
        rc.setValueId(getValueToSet(STRING.decode(object.get("valueId")), null));
        rc.setType(getValueToSet(STRING.decode(object.get("type")), null));
        rc.setValues(getValueToSet(toMap(object.get("values"), STRING, STRING, org.fusesource.restygwt.client.Json.Style.DEFAULT), null));
        rc.setInstanceId(getValueToSet(STRING.decode(object.get("instanceId")), null));
        rc.setId(getValueToSet(STRING.decode(object.get("id")), null));
        return rc;
      }
      
    }
