 /*
 * 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.request.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 FFStockVoSerializer implements BeanSerializer<com.today.api.purchase.request.FFStockVo>{
        
      @Override
      public com.today.api.purchase.request.FFStockVo read(TProtocol iprot) throws TException{

      com.today.api.purchase.request.FFStockVo bean = new com.today.api.purchase.request.FFStockVo();
      TField schemeField;
      iprot.readStructBegin();

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

        switch(schemeField.id){
          
              case 1:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setOwnerId(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 2:
              if(schemeField.type == TType.I32){
              com.today.api.stock.enums.StockOwnerTypeEnum elem0 = com.today.api.stock.enums.StockOwnerTypeEnum.findByValue(iprot.readI32());
       bean.setOwnerType(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 4:
              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.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setFfStockWeight(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 7:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setUseUnit(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 8:
              if(schemeField.type == TType.I32){
              com.today.api.stock.enums.StockJournalSourceTypeEnum elem0 = com.today.api.stock.enums.StockJournalSourceTypeEnum.findByValue(iprot.readI32());
       bean.setSourceType(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 9:
              if(schemeField.type == TType.I64){
              long elem0 = iprot.readI64();
       bean.setSourceTime(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 10:
              if(schemeField.type == TType.I64){
              long elem0 = iprot.readI64();
       bean.setOrderId(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 11:
              if(schemeField.type == TType.STRING){
              String elem0 = iprot.readString();
       bean.setSkuNo(elem0);
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 29:
              if(schemeField.type == TType.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setSellingPrice(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 30:
              if(schemeField.type == TType.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setBuyingPrice(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 31:
              if(schemeField.type == TType.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setLogisticsPrice(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 32:
              if(schemeField.type == TType.DOUBLE){
               double elem0 = iprot.readDouble();
       bean.setLogisticsOutputTax(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 33:
              if(schemeField.type == TType.STRING){
              java.math.BigDecimal elem0 = new java.math.BigDecimal(iprot.readString());
       bean.setLogisticsPriceAmount(Optional.of(elem0));
            }else{
              TProtocolUtil.skip(iprot, schemeField.type);
            }
              break;
            
              case 34:
              if(schemeField.type == TType.STRING){
              java.math.BigDecimal elem0 = new java.math.BigDecimal(iprot.readString());
       bean.setStoreSellingPriceAmount(Optional.of(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.request.FFStockVo bean, TProtocol oprot) throws TException{

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

      
            oprot.writeFieldBegin(new TField("ownerId", TType.STRING, (short) 1));
            String elem0 = bean.getOwnerId();
            oprot.writeString(elem0);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("ownerType", TType.I32, (short) 2));
            com.today.api.stock.enums.StockOwnerTypeEnum elem1 = bean.getOwnerType();
            oprot.writeI32(elem1.getValue());
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("ownerName", TType.STRING, (short) 4));
            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("ffStockWeight", TType.DOUBLE, (short) 6));
            Double elem4 = bean.getFfStockWeight();
            oprot.writeDouble(elem4);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("useUnit", TType.STRING, (short) 7));
            String elem5 = bean.getUseUnit();
            oprot.writeString(elem5);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("sourceType", TType.I32, (short) 8));
            com.today.api.stock.enums.StockJournalSourceTypeEnum elem6 = bean.getSourceType();
            oprot.writeI32(elem6.getValue());
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("sourceTime", TType.I64, (short) 9));
            Long elem7 = bean.getSourceTime();
            oprot.writeI64(elem7);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("orderId", TType.I64, (short) 10));
            Long elem8 = bean.getOrderId();
            oprot.writeI64(elem8);
            
            oprot.writeFieldEnd();
          
            oprot.writeFieldBegin(new TField("skuNo", TType.STRING, (short) 11));
            String elem9 = bean.getSkuNo();
            oprot.writeString(elem9);
            
            oprot.writeFieldEnd();
          if(bean.getSellingPrice().isPresent()){
              oprot.writeFieldBegin(new TField("sellingPrice", TType.DOUBLE, (short) 29));
              Double elem10 = bean.getSellingPrice().get();
              oprot.writeDouble(elem10);
              
            }
            if(bean.getBuyingPrice().isPresent()){
              oprot.writeFieldBegin(new TField("buyingPrice", TType.DOUBLE, (short) 30));
              Double elem11 = bean.getBuyingPrice().get();
              oprot.writeDouble(elem11);
              
            }
            if(bean.getLogisticsPrice().isPresent()){
              oprot.writeFieldBegin(new TField("logisticsPrice", TType.DOUBLE, (short) 31));
              Double elem12 = bean.getLogisticsPrice().get();
              oprot.writeDouble(elem12);
              
            }
            if(bean.getLogisticsOutputTax().isPresent()){
              oprot.writeFieldBegin(new TField("logisticsOutputTax", TType.DOUBLE, (short) 32));
              Double elem13 = bean.getLogisticsOutputTax().get();
              oprot.writeDouble(elem13);
              
            }
            if(bean.getLogisticsPriceAmount().isPresent()){
              oprot.writeFieldBegin(new TField("logisticsPriceAmount", TType.STRING, (short) 33));
              java.math.BigDecimal elem14 = bean.getLogisticsPriceAmount().get();
              oprot.writeString(elem14.toString());
              
            }
            if(bean.getStoreSellingPriceAmount().isPresent()){
              oprot.writeFieldBegin(new TField("storeSellingPriceAmount", TType.STRING, (short) 34));
              java.math.BigDecimal elem15 = bean.getStoreSellingPriceAmount().get();
              oprot.writeString(elem15.toString());
              
            }
            
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
    
      public void validate(com.today.api.purchase.request.FFStockVo bean) throws TException{
      
              if(bean.getOwnerId() == null)
              throw new SoaException(SoaCode.StructFieldNull, "ownerId字段不允许为空");
            
              if(bean.getOwnerType() == null)
              throw new SoaException(SoaCode.StructFieldNull, "ownerType字段不允许为空");
            
              if(bean.getOwnerName() == null)
              throw new SoaException(SoaCode.StructFieldNull, "ownerName字段不允许为空");
            
              if(bean.getSkuName() == null)
              throw new SoaException(SoaCode.StructFieldNull, "skuName字段不允许为空");
            
              if(bean.getUseUnit() == null)
              throw new SoaException(SoaCode.StructFieldNull, "useUnit字段不允许为空");
            
              if(bean.getSourceType() == null)
              throw new SoaException(SoaCode.StructFieldNull, "sourceType字段不允许为空");
            
              if(bean.getSkuNo() == null)
              throw new SoaException(SoaCode.StructFieldNull, "skuNo字段不允许为空");
            
    }
    
        @Override
        public String toString(com.today.api.purchase.request.FFStockVo bean)
        {return bean == null ? "null" : bean.toString();}
      }
      

      