{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeGuruProfiler.Types.Match where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 value in the profile data that exceeded the recommendation
    -- threshold.
    Match -> Maybe Double
thresholdBreachValue :: Prelude.Maybe Prelude.Double,
    -- | 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
  }
  deriving (Match -> Match -> Bool
(Match -> Match -> Bool) -> (Match -> Match -> Bool) -> Eq Match
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]
(Int -> ReadS Match)
-> ReadS [Match]
-> ReadPrec Match
-> ReadPrec [Match]
-> Read 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
(Int -> Match -> ShowS)
-> (Match -> String) -> ([Match] -> ShowS) -> Show Match
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. Match -> Rep Match x)
-> (forall x. Rep Match x -> Match) -> Generic Match
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:
--
-- 'thresholdBreachValue', 'match_thresholdBreachValue' - The value in the profile data that exceeded the recommendation
-- threshold.
--
-- '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.
newMatch ::
  Match
newMatch :: Match
newMatch =
  Match' :: Maybe Double -> Maybe Text -> Maybe Int -> Match
Match'
    { $sel:thresholdBreachValue:Match' :: Maybe Double
thresholdBreachValue = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:frameAddress:Match' :: Maybe Text
frameAddress = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetFramesIndex:Match' :: Maybe Int
targetFramesIndex = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The value in the profile data that exceeded the recommendation
-- threshold.
match_thresholdBreachValue :: Lens.Lens' Match (Prelude.Maybe Prelude.Double)
match_thresholdBreachValue :: (Maybe Double -> f (Maybe Double)) -> Match -> f Match
match_thresholdBreachValue = (Match -> Maybe Double)
-> (Match -> Maybe Double -> Match)
-> Lens Match Match (Maybe Double) (Maybe Double)
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)

-- | The location in the profiling graph that contains a recommendation found
-- during analysis.
match_frameAddress :: Lens.Lens' Match (Prelude.Maybe Prelude.Text)
match_frameAddress :: (Maybe Text -> f (Maybe Text)) -> Match -> f Match
match_frameAddress = (Match -> Maybe Text)
-> (Match -> Maybe Text -> Match)
-> Lens Match Match (Maybe Text) (Maybe Text)
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 :: (Maybe Int -> f (Maybe Int)) -> Match -> f Match
match_targetFramesIndex = (Match -> Maybe Int)
-> (Match -> Maybe Int -> Match)
-> Lens Match Match (Maybe Int) (Maybe Int)
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)

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

instance Prelude.Hashable Match

instance Prelude.NFData Match