{-# 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.Wisdom.Types.ResultData
-- 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.Wisdom.Types.ResultData 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
import Amazonka.Wisdom.Types.Document

-- | Information about the result.
--
-- /See:/ 'newResultData' smart constructor.
data ResultData = ResultData'
  { -- | The relevance score of the results.
    ResultData -> Maybe Double
relevanceScore :: Prelude.Maybe Prelude.Double,
    -- | The document.
    ResultData -> Document
document :: Document,
    -- | The identifier of the result data.
    ResultData -> Text
resultId :: Prelude.Text
  }
  deriving (ResultData -> ResultData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultData -> ResultData -> Bool
$c/= :: ResultData -> ResultData -> Bool
== :: ResultData -> ResultData -> Bool
$c== :: ResultData -> ResultData -> Bool
Prelude.Eq, Int -> ResultData -> ShowS
[ResultData] -> ShowS
ResultData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultData] -> ShowS
$cshowList :: [ResultData] -> ShowS
show :: ResultData -> String
$cshow :: ResultData -> String
showsPrec :: Int -> ResultData -> ShowS
$cshowsPrec :: Int -> ResultData -> ShowS
Prelude.Show, forall x. Rep ResultData x -> ResultData
forall x. ResultData -> Rep ResultData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultData x -> ResultData
$cfrom :: forall x. ResultData -> Rep ResultData x
Prelude.Generic)

-- |
-- Create a value of 'ResultData' 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:
--
-- 'relevanceScore', 'resultData_relevanceScore' - The relevance score of the results.
--
-- 'document', 'resultData_document' - The document.
--
-- 'resultId', 'resultData_resultId' - The identifier of the result data.
newResultData ::
  -- | 'document'
  Document ->
  -- | 'resultId'
  Prelude.Text ->
  ResultData
newResultData :: Document -> Text -> ResultData
newResultData Document
pDocument_ Text
pResultId_ =
  ResultData'
    { $sel:relevanceScore:ResultData' :: Maybe Double
relevanceScore = forall a. Maybe a
Prelude.Nothing,
      $sel:document:ResultData' :: Document
document = Document
pDocument_,
      $sel:resultId:ResultData' :: Text
resultId = Text
pResultId_
    }

-- | The relevance score of the results.
resultData_relevanceScore :: Lens.Lens' ResultData (Prelude.Maybe Prelude.Double)
resultData_relevanceScore :: Lens' ResultData (Maybe Double)
resultData_relevanceScore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultData' {Maybe Double
relevanceScore :: Maybe Double
$sel:relevanceScore:ResultData' :: ResultData -> Maybe Double
relevanceScore} -> Maybe Double
relevanceScore) (\s :: ResultData
s@ResultData' {} Maybe Double
a -> ResultData
s {$sel:relevanceScore:ResultData' :: Maybe Double
relevanceScore = Maybe Double
a} :: ResultData)

-- | The document.
resultData_document :: Lens.Lens' ResultData Document
resultData_document :: Lens' ResultData Document
resultData_document = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultData' {Document
document :: Document
$sel:document:ResultData' :: ResultData -> Document
document} -> Document
document) (\s :: ResultData
s@ResultData' {} Document
a -> ResultData
s {$sel:document:ResultData' :: Document
document = Document
a} :: ResultData)

-- | The identifier of the result data.
resultData_resultId :: Lens.Lens' ResultData Prelude.Text
resultData_resultId :: Lens' ResultData Text
resultData_resultId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultData' {Text
resultId :: Text
$sel:resultId:ResultData' :: ResultData -> Text
resultId} -> Text
resultId) (\s :: ResultData
s@ResultData' {} Text
a -> ResultData
s {$sel:resultId:ResultData' :: Text
resultId = Text
a} :: ResultData)

instance Data.FromJSON ResultData where
  parseJSON :: Value -> Parser ResultData
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResultData"
      ( \Object
x ->
          Maybe Double -> Document -> Text -> ResultData
ResultData'
            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
"relevanceScore")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"document")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"resultId")
      )

instance Prelude.Hashable ResultData where
  hashWithSalt :: Int -> ResultData -> Int
hashWithSalt Int
_salt ResultData' {Maybe Double
Text
Document
resultId :: Text
document :: Document
relevanceScore :: Maybe Double
$sel:resultId:ResultData' :: ResultData -> Text
$sel:document:ResultData' :: ResultData -> Document
$sel:relevanceScore:ResultData' :: ResultData -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
relevanceScore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Document
document
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resultId

instance Prelude.NFData ResultData where
  rnf :: ResultData -> ()
rnf ResultData' {Maybe Double
Text
Document
resultId :: Text
document :: Document
relevanceScore :: Maybe Double
$sel:resultId:ResultData' :: ResultData -> Text
$sel:document:ResultData' :: ResultData -> Document
$sel:relevanceScore:ResultData' :: ResultData -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
relevanceScore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Document
document
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resultId