packages feed

thrift-lib-0.1.0.1: gen-hs2/Thrift/Protocol/ApplicationException/Types.hs

-----------------------------------------------------------------
-- Autogenerated by Thrift
--
-- DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
--  @generated
-----------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -fno-warn-unused-imports#-}
{-# OPTIONS_GHC -fno-warn-overlapping-patterns#-}
{-# OPTIONS_GHC -fno-warn-incomplete-patterns#-}
{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns#-}
{-# OPTIONS_GHC -fno-warn-incomplete-record-updates#-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Thrift.Protocol.ApplicationException.Types
       (ApplicationExceptionType(ApplicationExceptionType_Unknown,
                                 ApplicationExceptionType_UnknownMethod,
                                 ApplicationExceptionType_InvalidMessageType,
                                 ApplicationExceptionType_WrongMethodType,
                                 ApplicationExceptionType_BadSequenceId,
                                 ApplicationExceptionType_MissingResult,
                                 ApplicationExceptionType_InternalError,
                                 ApplicationExceptionType_ProtocolError,
                                 ApplicationExceptionType_InvalidTransform,
                                 ApplicationExceptionType_InvalidProtocol,
                                 ApplicationExceptionType_UnsupportedClientType,
                                 ApplicationExceptionType_Loadshedding,
                                 ApplicationExceptionType_Timeout,
                                 ApplicationExceptionType_InjectedFailure,
                                 ApplicationExceptionType__UNKNOWN),
        ApplicationException(ApplicationException,
                             applicationException_message, applicationException_type))
       where
import qualified Control.DeepSeq as DeepSeq
import qualified Control.Exception as Exception
import qualified Control.Monad as Monad
import qualified Control.Monad.ST.Trans as ST
import qualified Control.Monad.Trans.Class as Trans
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Types as Aeson
import qualified Data.Default as Default
import qualified Data.Function as Function
import qualified Data.HashMap.Strict as HashMap
import qualified Data.Hashable as Hashable
import qualified Data.Int as Int
import qualified Data.List as List
import qualified Data.Ord as Ord
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import qualified GHC.Magic as GHC
import qualified Prelude as Prelude
import qualified Thrift.Binary.Parser as Parser
import qualified Thrift.CodegenTypesOnly as Thrift
import Control.Applicative ((<|>), (*>), (<*))
import Data.Aeson ((.:), (.:?), (.=), (.!=))
import Data.Monoid ((<>))
import Prelude ((.), (++), (>), (==))
import Prelude ((.), (<$>), (<*>), (>>=), (==), (/=), (<), (++))

data ApplicationExceptionType = ApplicationExceptionType_Unknown
                              | ApplicationExceptionType_UnknownMethod
                              | ApplicationExceptionType_InvalidMessageType
                              | ApplicationExceptionType_WrongMethodType
                              | ApplicationExceptionType_BadSequenceId
                              | ApplicationExceptionType_MissingResult
                              | ApplicationExceptionType_InternalError
                              | ApplicationExceptionType_ProtocolError
                              | ApplicationExceptionType_InvalidTransform
                              | ApplicationExceptionType_InvalidProtocol
                              | ApplicationExceptionType_UnsupportedClientType
                              | ApplicationExceptionType_Loadshedding
                              | ApplicationExceptionType_Timeout
                              | ApplicationExceptionType_InjectedFailure
                              | ApplicationExceptionType__UNKNOWN Prelude.Int
                                deriving (Prelude.Eq, Prelude.Show, Prelude.Ord)

instance Aeson.ToJSON ApplicationExceptionType where
  toJSON = Aeson.toJSON . Thrift.fromThriftEnum

instance DeepSeq.NFData ApplicationExceptionType where
  rnf __ApplicationExceptionType
    = Prelude.seq __ApplicationExceptionType ()

instance Default.Default ApplicationExceptionType where
  def = ApplicationExceptionType_Unknown

instance Hashable.Hashable ApplicationExceptionType where
  hashWithSalt _salt _val
    = Hashable.hashWithSalt _salt (Thrift.fromThriftEnum _val)

instance Thrift.ThriftEnum ApplicationExceptionType where
  toThriftEnum 0 = ApplicationExceptionType_Unknown
  toThriftEnum 1 = ApplicationExceptionType_UnknownMethod
  toThriftEnum 2 = ApplicationExceptionType_InvalidMessageType
  toThriftEnum 3 = ApplicationExceptionType_WrongMethodType
  toThriftEnum 4 = ApplicationExceptionType_BadSequenceId
  toThriftEnum 5 = ApplicationExceptionType_MissingResult
  toThriftEnum 6 = ApplicationExceptionType_InternalError
  toThriftEnum 7 = ApplicationExceptionType_ProtocolError
  toThriftEnum 8 = ApplicationExceptionType_InvalidTransform
  toThriftEnum 9 = ApplicationExceptionType_InvalidProtocol
  toThriftEnum 10 = ApplicationExceptionType_UnsupportedClientType
  toThriftEnum 11 = ApplicationExceptionType_Loadshedding
  toThriftEnum 12 = ApplicationExceptionType_Timeout
  toThriftEnum 13 = ApplicationExceptionType_InjectedFailure
  toThriftEnum val = ApplicationExceptionType__UNKNOWN val
  fromThriftEnum ApplicationExceptionType_Unknown = 0
  fromThriftEnum ApplicationExceptionType_UnknownMethod = 1
  fromThriftEnum ApplicationExceptionType_InvalidMessageType = 2
  fromThriftEnum ApplicationExceptionType_WrongMethodType = 3
  fromThriftEnum ApplicationExceptionType_BadSequenceId = 4
  fromThriftEnum ApplicationExceptionType_MissingResult = 5
  fromThriftEnum ApplicationExceptionType_InternalError = 6
  fromThriftEnum ApplicationExceptionType_ProtocolError = 7
  fromThriftEnum ApplicationExceptionType_InvalidTransform = 8
  fromThriftEnum ApplicationExceptionType_InvalidProtocol = 9
  fromThriftEnum ApplicationExceptionType_UnsupportedClientType = 10
  fromThriftEnum ApplicationExceptionType_Loadshedding = 11
  fromThriftEnum ApplicationExceptionType_Timeout = 12
  fromThriftEnum ApplicationExceptionType_InjectedFailure = 13
  fromThriftEnum (ApplicationExceptionType__UNKNOWN val) = val
  allThriftEnumValues
    = [ApplicationExceptionType_Unknown,
       ApplicationExceptionType_UnknownMethod,
       ApplicationExceptionType_InvalidMessageType,
       ApplicationExceptionType_WrongMethodType,
       ApplicationExceptionType_BadSequenceId,
       ApplicationExceptionType_MissingResult,
       ApplicationExceptionType_InternalError,
       ApplicationExceptionType_ProtocolError,
       ApplicationExceptionType_InvalidTransform,
       ApplicationExceptionType_InvalidProtocol,
       ApplicationExceptionType_UnsupportedClientType,
       ApplicationExceptionType_Loadshedding,
       ApplicationExceptionType_Timeout,
       ApplicationExceptionType_InjectedFailure]
  toThriftEnumEither 0
    = Prelude.Right ApplicationExceptionType_Unknown
  toThriftEnumEither 1
    = Prelude.Right ApplicationExceptionType_UnknownMethod
  toThriftEnumEither 2
    = Prelude.Right ApplicationExceptionType_InvalidMessageType
  toThriftEnumEither 3
    = Prelude.Right ApplicationExceptionType_WrongMethodType
  toThriftEnumEither 4
    = Prelude.Right ApplicationExceptionType_BadSequenceId
  toThriftEnumEither 5
    = Prelude.Right ApplicationExceptionType_MissingResult
  toThriftEnumEither 6
    = Prelude.Right ApplicationExceptionType_InternalError
  toThriftEnumEither 7
    = Prelude.Right ApplicationExceptionType_ProtocolError
  toThriftEnumEither 8
    = Prelude.Right ApplicationExceptionType_InvalidTransform
  toThriftEnumEither 9
    = Prelude.Right ApplicationExceptionType_InvalidProtocol
  toThriftEnumEither 10
    = Prelude.Right ApplicationExceptionType_UnsupportedClientType
  toThriftEnumEither 11
    = Prelude.Right ApplicationExceptionType_Loadshedding
  toThriftEnumEither 12
    = Prelude.Right ApplicationExceptionType_Timeout
  toThriftEnumEither 13
    = Prelude.Right ApplicationExceptionType_InjectedFailure
  toThriftEnumEither val
    = Prelude.Left
        ("toThriftEnumEither: not a valid identifier for enum ApplicationExceptionType: "
           ++ Prelude.show val)

data ApplicationException = ApplicationException{applicationException_message
                                                 :: Text.Text,
                                                 applicationException_type ::
                                                 ApplicationExceptionType}
                            deriving (Prelude.Eq, Prelude.Show, Prelude.Ord)

instance Aeson.ToJSON ApplicationException where
  toJSON (ApplicationException __field__message __field__type)
    = Aeson.object
        ("message" .= __field__message :
           "type" .= __field__type : Prelude.mempty)

instance Thrift.ThriftStruct ApplicationException where
  buildStruct _proxy
    (ApplicationException __field__message __field__type)
    = Thrift.genStruct _proxy
        (Thrift.genField _proxy "message" (Thrift.getStringType _proxy) 1 0
           (Thrift.genText _proxy __field__message)
           :
           Thrift.genField _proxy "type" (Thrift.getI32Type _proxy) 2 1
             ((Thrift.genI32 _proxy . Prelude.fromIntegral .
                 Thrift.fromThriftEnum)
                __field__type)
             : [])
  parseStruct _proxy
    = ST.runSTT
        (do Prelude.return ()
            __field__message <- ST.newSTRef ""
            __field__type <- ST.newSTRef Default.def
            let
              _parse _lastId
                = do _fieldBegin <- Trans.lift
                                      (Thrift.parseFieldBegin _proxy _lastId _idMap)
                     case _fieldBegin of
                       Thrift.FieldBegin _type _id _bool -> do case _id of
                                                                 1 | _type ==
                                                                       Thrift.getStringType _proxy
                                                                     ->
                                                                     do !_val <- Trans.lift
                                                                                   (Thrift.parseText
                                                                                      _proxy)
                                                                        ST.writeSTRef
                                                                          __field__message
                                                                          _val
                                                                 2 | _type ==
                                                                       Thrift.getI32Type _proxy
                                                                     ->
                                                                     do !_val <- Trans.lift
                                                                                   (Thrift.parseEnum
                                                                                      _proxy
                                                                                      "ApplicationExceptionType")
                                                                        ST.writeSTRef __field__type
                                                                          _val
                                                                 _ -> Trans.lift
                                                                        (Thrift.parseSkip _proxy
                                                                           _type
                                                                           (Prelude.Just _bool))
                                                               _parse _id
                       Thrift.FieldEnd -> do !__val__message <- ST.readSTRef
                                                                  __field__message
                                             !__val__type <- ST.readSTRef __field__type
                                             Prelude.pure
                                               (ApplicationException __val__message __val__type)
              _idMap = HashMap.fromList [("message", 1), ("type", 2)]
            _parse 0)

instance DeepSeq.NFData ApplicationException where
  rnf (ApplicationException __field__message __field__type)
    = DeepSeq.rnf __field__message `Prelude.seq`
        DeepSeq.rnf __field__type `Prelude.seq` ()

instance Default.Default ApplicationException where
  def = ApplicationException "" Default.def

instance Hashable.Hashable ApplicationException where
  hashWithSalt __salt (ApplicationException _message _type)
    = Hashable.hashWithSalt (Hashable.hashWithSalt __salt _message)
        _type

instance Exception.Exception ApplicationException