{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CodeGuruProfiler.Types.Match
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeGuruProfiler.Types.Match where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The part of a profile that contains a recommendation found during
-- analysis.
--
-- /See:/ 'newMatch' smart constructor.
data Match = Match'
  { -- | The location in the profiling graph that contains a recommendation found
    -- during analysis.
    Match -> Maybe Text
frameAddress :: Prelude.Maybe Prelude.Text,
    -- | The target frame that triggered a match.
    Match -> Maybe Int
targetFramesIndex :: Prelude.Maybe Prelude.Int,
    -- | The value in the profile data that exceeded the recommendation
    -- threshold.
    Match -> Maybe Double
thresholdBreachValue :: Prelude.Maybe Prelude.Double
  }
  deriving (Match -> Match -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Match -> Match -> Bool
$c/= :: Match -> Match -> Bool
== :: Match -> Match -> Bool
$c== :: Match -> Match -> Bool
Prelude.Eq, ReadPrec [Match]
ReadPrec Match
Int -> ReadS Match
ReadS [Match]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Match]
$creadListPrec :: ReadPrec [Match]
readPrec :: ReadPrec Match
$creadPrec :: ReadPrec Match
readList :: ReadS [Match]
$creadList :: ReadS [Match]
readsPrec :: Int -> ReadS Match
$creadsPrec :: Int -> ReadS Match
Prelude.Read, Int -> Match -> ShowS
[Match] -> ShowS
Match -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Match] -> ShowS
$cshowList :: [Match] -> ShowS
show :: Match -> String
$cshow :: Match -> String
showsPrec :: Int -> Match -> ShowS
$cshowsPrec :: Int -> Match -> ShowS
Prelude.Show, forall x. Rep Match x -> Match
forall x. Match -> Rep Match x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Match x -> Match
$cfrom :: forall x. Match -> Rep Match x
Prelude.Generic)

-- |
-- Create a value of 'Match' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'frameAddress', 'match_frameAddress' - The location in the profiling graph that contains a recommendation found
-- during analysis.
--
-- 'targetFramesIndex', 'match_targetFramesIndex' - The target frame that triggered a match.
--
-- 'thresholdBreachValue', 'match_thresholdBreachValue' - The value in the profile data that exceeded the recommendation
-- threshold.
newMatch ::
  Match
newMatch :: Match
newMatch =
  Match'
    { $sel:frameAddress:Match' :: Maybe Text
frameAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:targetFramesIndex:Match' :: Maybe Int
targetFramesIndex = forall a. Maybe a
Prelude.Nothing,
      $sel:thresholdBreachValue:Match' :: Maybe Double
thresholdBreachValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The location in the profiling graph that contains a recommendation found
-- during analysis.
match_frameAddress :: Lens.Lens' Match (Prelude.Maybe Prelude.Text)
match_frameAddress :: Lens' Match (Maybe Text)
match_frameAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Match' {Maybe Text
frameAddress :: Maybe Text
$sel:frameAddress:Match' :: Match -> Maybe Text
frameAddress} -> Maybe Text
frameAddress) (\s :: Match
s@Match' {} Maybe Text
a -> Match
s {$sel:frameAddress:Match' :: Maybe Text
frameAddress = Maybe Text
a} :: Match)

-- | The target frame that triggered a match.
match_targetFramesIndex :: Lens.Lens' Match (Prelude.Maybe Prelude.Int)
match_targetFramesIndex :: Lens' Match (Maybe Int)
match_targetFramesIndex = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Match' {Maybe Int
targetFramesIndex :: Maybe Int
$sel:targetFramesIndex:Match' :: Match -> Maybe Int
targetFramesIndex} -> Maybe Int
targetFramesIndex) (\s :: Match
s@Match' {} Maybe Int
a -> Match
s {$sel:targetFramesIndex:Match' :: Maybe Int
targetFramesIndex = Maybe Int
a} :: Match)

-- | The value in the profile data that exceeded the recommendation
-- threshold.
match_thresholdBreachValue :: Lens.Lens' Match (Prelude.Maybe Prelude.Double)
match_thresholdBreachValue :: Lens' Match (Maybe Double)
match_thresholdBreachValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Match' {Maybe Double
thresholdBreachValue :: Maybe Double
$sel:thresholdBreachValue:Match' :: Match -> Maybe Double
thresholdBreachValue} -> Maybe Double
thresholdBreachValue) (\s :: Match
s@Match' {} Maybe Double
a -> Match
s {$sel:thresholdBreachValue:Match' :: Maybe Double
thresholdBreachValue = Maybe Double
a} :: Match)

instance Data.FromJSON Match where
  parseJSON :: Value -> Parser Match
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Match"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> Maybe Double -> Match
Match'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"frameAddress")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"targetFramesIndex")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"thresholdBreachValue")
      )

instance Prelude.Hashable Match where
  hashWithSalt :: Int -> Match -> Int
hashWithSalt Int
_salt Match' {Maybe Double
Maybe Int
Maybe Text
thresholdBreachValue :: Maybe Double
targetFramesIndex :: Maybe Int
frameAddress :: Maybe Text
$sel:thresholdBreachValue:Match' :: Match -> Maybe Double
$sel:targetFramesIndex:Match' :: Match -> Maybe Int
$sel:frameAddress:Match' :: Match -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
frameAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
targetFramesIndex
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
thresholdBreachValue

instance Prelude.NFData Match where
  rnf :: Match -> ()
rnf Match' {Maybe Double
Maybe Int
Maybe Text
thresholdBreachValue :: Maybe Double
targetFramesIndex :: Maybe Int
frameAddress :: Maybe Text
$sel:thresholdBreachValue:Match' :: Match -> Maybe Double
$sel:targetFramesIndex:Match' :: Match -> Maybe Int
$sel:frameAddress:Match' :: Match -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
frameAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
targetFramesIndex
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
thresholdBreachValue