 /*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.today.api.purchase.response.serializer;
        import com.today.api.purchase.request.serializer.*;import com.today.api.common.serializer.*;import com.today.api.purchase.response.serializer.*;import com.today.api.stock.response.serializer.*;import com.today.api.stock.request.serializer.*;import com.today.api.stock.events.serializer.*;import com.today.api.stock.vo.serializer.*;

        import com.github.dapeng.core.*;
        import com.github.dapeng.org.apache.thrift.*;
        import com.github.dapeng.org.apache.thrift.protocol.*;

        import java.util.Optional;
        import java.util.concurrent.CompletableFuture;
        import java.util.concurrent.Future;

        /**
        * Autogenerated by Dapeng-Code-Generator (2.2.0)
        *
        * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
        *
        **/
        public class SkuStockItemSerializer implements BeanSerializer<com.today.api.purchase.response.SkuStockItem>{
        
      @Override
      public com.today.api.purchase.response.SkuStockItem read(TProtocol iprot) throws TException{

      com.today.api.purchase.response.SkuStockItem bean = new com.today.api.purchase.response.SkuStockItem();
      TField schemeField;
      iprot.readStructBegin();

      while(true){
        schemeField = iprot.readFieldBegin();
        if(schemeField.type == TType.STOP){ break;}

        switch(schemeField.id){
          
              case 1:
              if(schemeField.type == TType.I64){
              long elem0 = iprot.readI64();
       bean.setId(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 2:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setStoreId(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 3:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setOwnerName(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 5:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setSkuName(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 6:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setSkuNo(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 7:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setMasterBarcode(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 8:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setSpec(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 9:
              if(schemeField.type == TType.STRING){
              java.math.BigDecimal elem0 = new java.math.BigDecimal(iprot.readString());
       bean.setStockNum(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 10:
              if(schemeField.type == TType.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setFfStockWeight(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 11:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setUseUnit(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 12:
              if(schemeField.type == TType.I64){
              long elem0 = iprot.readI64();
       bean.setLastBalanceStock(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 13:
              if(schemeField.type == TType.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setLastBalanceFfStock(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 14:
              if(schemeField.type == TType.I64){
              long elem0 = iprot.readI64();
       bean.setFinanceStock(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 15:
              if(schemeField.type == TType.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setFinanceFfStock(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 16:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setSaleUnitName(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 17:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setSaleUnitValue(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 18:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setShippingMethodValue(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 19:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setShippingMethodName(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 20:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setSkuTypeName(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 21:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setSkuTypeValue(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 22:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setCategoryCodeA(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 23:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setCategoryCodeC(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 24:
              if(schemeField.type == TType.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setSellingPrice(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 25:
              if(schemeField.type == TType.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setTotalSellingPrice(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
          
            default:
            TProtocolUtil.skip(iprot, schemeField.type);
          
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      validate(bean);
      return bean;
    }
    
      @Override
      public void write(com.today.api.purchase.response.SkuStockItem bean, TProtocol oprot) throws TException{

      validate(bean);
      oprot.writeStructBegin(new TStruct("SkuStockItem"));

      
            oprot.writeFieldBegin(new TField("id", TType.I64, (short) 1));
            Long elem0 = bean.getId();
            oprot.writeI64(elem0);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("storeId", TType.STRING, (short) 2));
            String elem1 = bean.getStoreId();
            oprot.writeString(elem1);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("ownerName", TType.STRING, (short) 3));
            String elem2 = bean.getOwnerName();
            oprot.writeString(elem2);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("skuName", TType.STRING, (short) 5));
            String elem3 = bean.getSkuName();
            oprot.writeString(elem3);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("skuNo", TType.STRING, (short) 6));
            String elem4 = bean.getSkuNo();
            oprot.writeString(elem4);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("masterBarcode", TType.STRING, (short) 7));
            String elem5 = bean.getMasterBarcode();
            oprot.writeString(elem5);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("spec", TType.STRING, (short) 8));
            String elem6 = bean.getSpec();
            oprot.writeString(elem6);
            
            oprot.writeFieldEnd();
          if(bean.getStockNum().isPresent()){
              oprot.writeFieldBegin(new TField("stockNum", TType.STRING, (short) 9));
              java.math.BigDecimal elem7 = bean.getStockNum().get();
              oprot.writeString(elem7.toString());
              
            }
            if(bean.getFfStockWeight().isPresent()){
              oprot.writeFieldBegin(new TField("ffStockWeight", TType.DOUBLE, (short) 10));
              Double elem8 = bean.getFfStockWeight().get();
              oprot.writeDouble(elem8);
              
            }
            if(bean.getUseUnit().isPresent()){
              oprot.writeFieldBegin(new TField("useUnit", TType.STRING, (short) 11));
              String elem9 = bean.getUseUnit().get();
              oprot.writeString(elem9);
              
            }
            if(bean.getLastBalanceStock().isPresent()){
              oprot.writeFieldBegin(new TField("lastBalanceStock", TType.I64, (short) 12));
              Long elem10 = bean.getLastBalanceStock().get();
              oprot.writeI64(elem10);
              
            }
            if(bean.getLastBalanceFfStock().isPresent()){
              oprot.writeFieldBegin(new TField("lastBalanceFfStock", TType.DOUBLE, (short) 13));
              Double elem11 = bean.getLastBalanceFfStock().get();
              oprot.writeDouble(elem11);
              
            }
            if(bean.getFinanceStock().isPresent()){
              oprot.writeFieldBegin(new TField("financeStock", TType.I64, (short) 14));
              Long elem12 = bean.getFinanceStock().get();
              oprot.writeI64(elem12);
              
            }
            if(bean.getFinanceFfStock().isPresent()){
              oprot.writeFieldBegin(new TField("financeFfStock", TType.DOUBLE, (short) 15));
              Double elem13 = bean.getFinanceFfStock().get();
              oprot.writeDouble(elem13);
              
            }
            
            oprot.writeFieldBegin(new TField("saleUnitName", TType.STRING, (short) 16));
            String elem14 = bean.getSaleUnitName();
            oprot.writeString(elem14);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("saleUnitValue", TType.STRING, (short) 17));
            String elem15 = bean.getSaleUnitValue();
            oprot.writeString(elem15);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("shippingMethodValue", TType.STRING, (short) 18));
            String elem16 = bean.getShippingMethodValue();
            oprot.writeString(elem16);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("shippingMethodName", TType.STRING, (short) 19));
            String elem17 = bean.getShippingMethodName();
            oprot.writeString(elem17);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("skuTypeName", TType.STRING, (short) 20));
            String elem18 = bean.getSkuTypeName();
            oprot.writeString(elem18);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("skuTypeValue", TType.STRING, (short) 21));
            String elem19 = bean.getSkuTypeValue();
            oprot.writeString(elem19);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("categoryCodeA", TType.STRING, (short) 22));
            String elem20 = bean.getCategoryCodeA();
            oprot.writeString(elem20);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("categoryCodeC", TType.STRING, (short) 23));
            String elem21 = bean.getCategoryCodeC();
            oprot.writeString(elem21);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("sellingPrice", TType.DOUBLE, (short) 24));
            Double elem22 = bean.getSellingPrice();
            oprot.writeDouble(elem22);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("totalSellingPrice", TType.DOUBLE, (short) 25));
            Double elem23 = bean.getTotalSellingPrice();
            oprot.writeDouble(elem23);
            
            oprot.writeFieldEnd();
          
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
    
      public void validate(com.today.api.purchase.response.SkuStockItem bean) throws TException{
      
              if(bean.getStoreId() == null)
              throw new SoaException(SoaCode.StructFieldNull, "storeId字段不允许为空");
            
              if(bean.getOwnerName() == null)
              throw new SoaException(SoaCode.StructFieldNull, "ownerName字段不允许为空");
            
              if(bean.getSkuName() == null)
              throw new SoaException(SoaCode.StructFieldNull, "skuName字段不允许为空");
            
              if(bean.getSkuNo() == null)
              throw new SoaException(SoaCode.StructFieldNull, "skuNo字段不允许为空");
            
              if(bean.getMasterBarcode() == null)
              throw new SoaException(SoaCode.StructFieldNull, "masterBarcode字段不允许为空");
            
              if(bean.getSpec() == null)
              throw new SoaException(SoaCode.StructFieldNull, "spec字段不允许为空");
            
              if(bean.getSaleUnitName() == null)
              throw new SoaException(SoaCode.StructFieldNull, "saleUnitName字段不允许为空");
            
              if(bean.getSaleUnitValue() == null)
              throw new SoaException(SoaCode.StructFieldNull, "saleUnitValue字段不允许为空");
            
              if(bean.getShippingMethodValue() == null)
              throw new SoaException(SoaCode.StructFieldNull, "shippingMethodValue字段不允许为空");
            
              if(bean.getShippingMethodName() == null)
              throw new SoaException(SoaCode.StructFieldNull, "shippingMethodName字段不允许为空");
            
              if(bean.getSkuTypeName() == null)
              throw new SoaException(SoaCode.StructFieldNull, "skuTypeName字段不允许为空");
            
              if(bean.getSkuTypeValue() == null)
              throw new SoaException(SoaCode.StructFieldNull, "skuTypeValue字段不允许为空");
            
              if(bean.getCategoryCodeA() == null)
              throw new SoaException(SoaCode.StructFieldNull, "categoryCodeA字段不允许为空");
            
              if(bean.getCategoryCodeC() == null)
              throw new SoaException(SoaCode.StructFieldNull, "categoryCodeC字段不允许为空");
            
    }
    
        @Override
        public String toString(com.today.api.purchase.response.SkuStockItem bean)
        {return bean == null ? "null" : bean.toString();}
      }
      

      