-- THIS IS A GENERATED FILE, DO NOT EDIT

{-# OPTIONS_GHC -Wno-unused-imports #-}
{-# OPTIONS_GHC -Wno-unused-matches #-}
{-# OPTIONS_GHC -Wno-deprecations #-}
module Language.LSP.Protocol.Internal.Types.ResourceOperation where

import Control.DeepSeq
import Data.Hashable
import GHC.Generics
import qualified Data.Aeson as Aeson
import qualified Data.Row.Aeson as Aeson
import qualified Data.Row.Hashable as Hashable
import qualified Data.Text
import qualified Language.LSP.Protocol.Internal.Types.ChangeAnnotationIdentifier
import qualified Language.LSP.Protocol.Types.Common

{-|
A generic resource operation.
-}
data ResourceOperation = ResourceOperation 
  { {-|
  The resource operation kind.
  -}
  ResourceOperation -> Text
_kind :: Data.Text.Text
  , {-|
  An optional annotation identifier describing the operation.

  @since 3.16.0
  -}
  ResourceOperation -> Maybe ChangeAnnotationIdentifier
_annotationId :: (Maybe Language.LSP.Protocol.Internal.Types.ChangeAnnotationIdentifier.ChangeAnnotationIdentifier)
  }
  deriving stock (Int -> ResourceOperation -> ShowS
[ResourceOperation] -> ShowS
ResourceOperation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceOperation] -> ShowS
$cshowList :: [ResourceOperation] -> ShowS
show :: ResourceOperation -> String
$cshow :: ResourceOperation -> String
showsPrec :: Int -> ResourceOperation -> ShowS
$cshowsPrec :: Int -> ResourceOperation -> ShowS
Show, ResourceOperation -> ResourceOperation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceOperation -> ResourceOperation -> Bool
$c/= :: ResourceOperation -> ResourceOperation -> Bool
== :: ResourceOperation -> ResourceOperation -> Bool
$c== :: ResourceOperation -> ResourceOperation -> Bool
Eq, Eq ResourceOperation
ResourceOperation -> ResourceOperation -> Bool
ResourceOperation -> ResourceOperation -> Ordering
ResourceOperation -> ResourceOperation -> ResourceOperation
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ResourceOperation -> ResourceOperation -> ResourceOperation
$cmin :: ResourceOperation -> ResourceOperation -> ResourceOperation
max :: ResourceOperation -> ResourceOperation -> ResourceOperation
$cmax :: ResourceOperation -> ResourceOperation -> ResourceOperation
>= :: ResourceOperation -> ResourceOperation -> Bool
$c>= :: ResourceOperation -> ResourceOperation -> Bool
> :: ResourceOperation -> ResourceOperation -> Bool
$c> :: ResourceOperation -> ResourceOperation -> Bool
<= :: ResourceOperation -> ResourceOperation -> Bool
$c<= :: ResourceOperation -> ResourceOperation -> Bool
< :: ResourceOperation -> ResourceOperation -> Bool
$c< :: ResourceOperation -> ResourceOperation -> Bool
compare :: ResourceOperation -> ResourceOperation -> Ordering
$ccompare :: ResourceOperation -> ResourceOperation -> Ordering
Ord, forall x. Rep ResourceOperation x -> ResourceOperation
forall x. ResourceOperation -> Rep ResourceOperation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceOperation x -> ResourceOperation
$cfrom :: forall x. ResourceOperation -> Rep ResourceOperation x
Generic)
  deriving anyclass (ResourceOperation -> ()
forall a. (a -> ()) -> NFData a
rnf :: ResourceOperation -> ()
$crnf :: ResourceOperation -> ()
NFData, Eq ResourceOperation
Int -> ResourceOperation -> Int
ResourceOperation -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: ResourceOperation -> Int
$chash :: ResourceOperation -> Int
hashWithSalt :: Int -> ResourceOperation -> Int
$chashWithSalt :: Int -> ResourceOperation -> Int
Hashable)

instance Aeson.ToJSON ResourceOperation where
  toJSON :: ResourceOperation -> Value
toJSON (ResourceOperation Text
arg0 Maybe ChangeAnnotationIdentifier
arg1) = [Pair] -> Value
Aeson.object forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall a b. (a -> b) -> a -> b
$  [[Key
"kind" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Aeson..= Text
arg0]
    ,String
"annotationId" forall kv v. (KeyValue kv, ToJSON v) => String -> Maybe v -> [kv]
Language.LSP.Protocol.Types.Common..=? Maybe ChangeAnnotationIdentifier
arg1]

instance Aeson.FromJSON ResourceOperation where
  parseJSON :: Value -> Parser ResourceOperation
parseJSON = forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"ResourceOperation" forall a b. (a -> b) -> a -> b
$ \Object
arg -> Text -> Maybe ChangeAnnotationIdentifier -> ResourceOperation
ResourceOperation forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
arg forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"kind" forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
arg forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Aeson..:! Key
"annotationId"