{- ORMOLU_DISABLE -}
{- HLINT ignore -}
-- 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 Language.LSP.Protocol.Utils.Misc
import Prettyprinter
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
(Int -> ResourceOperation -> ShowS)
-> (ResourceOperation -> String)
-> ([ResourceOperation] -> ShowS)
-> Show ResourceOperation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ResourceOperation -> ShowS
showsPrec :: Int -> ResourceOperation -> ShowS
$cshow :: ResourceOperation -> String
show :: ResourceOperation -> String
$cshowList :: [ResourceOperation] -> ShowS
showList :: [ResourceOperation] -> ShowS
Show, ResourceOperation -> ResourceOperation -> Bool
(ResourceOperation -> ResourceOperation -> Bool)
-> (ResourceOperation -> ResourceOperation -> Bool)
-> Eq ResourceOperation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ResourceOperation -> ResourceOperation -> Bool
== :: ResourceOperation -> ResourceOperation -> Bool
$c/= :: ResourceOperation -> ResourceOperation -> Bool
/= :: ResourceOperation -> ResourceOperation -> Bool
Eq, Eq ResourceOperation
Eq ResourceOperation =>
(ResourceOperation -> ResourceOperation -> Ordering)
-> (ResourceOperation -> ResourceOperation -> Bool)
-> (ResourceOperation -> ResourceOperation -> Bool)
-> (ResourceOperation -> ResourceOperation -> Bool)
-> (ResourceOperation -> ResourceOperation -> Bool)
-> (ResourceOperation -> ResourceOperation -> ResourceOperation)
-> (ResourceOperation -> ResourceOperation -> ResourceOperation)
-> Ord 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
$ccompare :: ResourceOperation -> ResourceOperation -> Ordering
compare :: ResourceOperation -> ResourceOperation -> Ordering
$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
>= :: ResourceOperation -> ResourceOperation -> Bool
$cmax :: ResourceOperation -> ResourceOperation -> ResourceOperation
max :: ResourceOperation -> ResourceOperation -> ResourceOperation
$cmin :: ResourceOperation -> ResourceOperation -> ResourceOperation
min :: ResourceOperation -> ResourceOperation -> ResourceOperation
Ord, (forall x. ResourceOperation -> Rep ResourceOperation x)
-> (forall x. Rep ResourceOperation x -> ResourceOperation)
-> Generic ResourceOperation
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
$cfrom :: forall x. ResourceOperation -> Rep ResourceOperation x
from :: forall x. ResourceOperation -> Rep ResourceOperation x
$cto :: forall x. Rep ResourceOperation x -> ResourceOperation
to :: forall x. Rep ResourceOperation x -> ResourceOperation
Generic)
  deriving anyclass (ResourceOperation -> ()
(ResourceOperation -> ()) -> NFData ResourceOperation
forall a. (a -> ()) -> NFData a
$crnf :: ResourceOperation -> ()
rnf :: ResourceOperation -> ()
NFData, Eq ResourceOperation
Eq ResourceOperation =>
(Int -> ResourceOperation -> Int)
-> (ResourceOperation -> Int) -> Hashable ResourceOperation
Int -> ResourceOperation -> Int
ResourceOperation -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ResourceOperation -> Int
hashWithSalt :: Int -> ResourceOperation -> Int
$chash :: ResourceOperation -> Int
hash :: ResourceOperation -> Int
Hashable)
  deriving (forall ann. ResourceOperation -> Doc ann)
-> (forall ann. [ResourceOperation] -> Doc ann)
-> Pretty ResourceOperation
forall ann. [ResourceOperation] -> Doc ann
forall ann. ResourceOperation -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. ResourceOperation -> Doc ann
pretty :: forall ann. ResourceOperation -> Doc ann
$cprettyList :: forall ann. [ResourceOperation] -> Doc ann
prettyList :: forall ann. [ResourceOperation] -> Doc ann
Pretty via (ViaJSON ResourceOperation)

instance Aeson.ToJSON ResourceOperation where
  toJSON :: ResourceOperation -> Value
toJSON (ResourceOperation Text
arg0 Maybe ChangeAnnotationIdentifier
arg1) = [Pair] -> Value
Aeson.object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[Pair]] -> [Pair]) -> [[Pair]] -> [Pair]
forall a b. (a -> b) -> a -> b
$  [[Key
"kind" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= Text
arg0]
    ,String
"annotationId" String -> Maybe ChangeAnnotationIdentifier -> [Pair]
forall e kv v.
(KeyValue e 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 = String
-> (Object -> Parser ResourceOperation)
-> Value
-> Parser ResourceOperation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"ResourceOperation" ((Object -> Parser ResourceOperation)
 -> Value -> Parser ResourceOperation)
-> (Object -> Parser ResourceOperation)
-> Value
-> Parser ResourceOperation
forall a b. (a -> b) -> a -> b
$ \Object
arg -> Text -> Maybe ChangeAnnotationIdentifier -> ResourceOperation
ResourceOperation (Text -> Maybe ChangeAnnotationIdentifier -> ResourceOperation)
-> Parser Text
-> Parser (Maybe ChangeAnnotationIdentifier -> ResourceOperation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
arg Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"kind" Parser (Maybe ChangeAnnotationIdentifier -> ResourceOperation)
-> Parser (Maybe ChangeAnnotationIdentifier)
-> Parser ResourceOperation
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
arg Object -> Key -> Parser (Maybe ChangeAnnotationIdentifier)
forall v. FromJSON v => Object -> Key -> Parser (Maybe v)
Language.LSP.Protocol.Types.Common..:!? Key
"annotationId"