{-# 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-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.Wisdom.Types.ResultData where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ResultData -> ResultData -> Bool)
-> (ResultData -> ResultData -> Bool) -> Eq ResultData
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
(Int -> ResultData -> ShowS)
-> (ResultData -> String)
-> ([ResultData] -> ShowS)
-> Show ResultData
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. ResultData -> Rep ResultData x)
-> (forall x. Rep ResultData x -> ResultData) -> Generic ResultData
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' :: Maybe Double -> Document -> Text -> ResultData
ResultData'
    { $sel:relevanceScore:ResultData' :: Maybe Double
relevanceScore = Maybe Double
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 :: (Maybe Double -> f (Maybe Double)) -> ResultData -> f ResultData
resultData_relevanceScore = (ResultData -> Maybe Double)
-> (ResultData -> Maybe Double -> ResultData)
-> Lens ResultData ResultData (Maybe Double) (Maybe Double)
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 :: (Document -> f Document) -> ResultData -> f ResultData
resultData_document = (ResultData -> Document)
-> (ResultData -> Document -> ResultData)
-> Lens ResultData ResultData Document 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 :: (Text -> f Text) -> ResultData -> f ResultData
resultData_resultId = (ResultData -> Text)
-> (ResultData -> Text -> ResultData)
-> Lens ResultData ResultData Text Text
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 Core.FromJSON ResultData where
  parseJSON :: Value -> Parser ResultData
parseJSON =
    String
-> (Object -> Parser ResultData) -> Value -> Parser ResultData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResultData"
      ( \Object
x ->
          Maybe Double -> Document -> Text -> ResultData
ResultData'
            (Maybe Double -> Document -> Text -> ResultData)
-> Parser (Maybe Double) -> Parser (Document -> Text -> ResultData)
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
"relevanceScore")
            Parser (Document -> Text -> ResultData)
-> Parser Document -> Parser (Text -> ResultData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Document
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"document")
            Parser (Text -> ResultData) -> Parser Text -> Parser ResultData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"resultId")
      )

instance Prelude.Hashable ResultData

instance Prelude.NFData ResultData