{-# 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.SearchExpression
-- 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.SearchExpression 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.Filter

-- | The search expression.
--
-- /See:/ 'newSearchExpression' smart constructor.
data SearchExpression = SearchExpression'
  { -- | The search expression filters.
    SearchExpression -> [Filter]
filters :: [Filter]
  }
  deriving (SearchExpression -> SearchExpression -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchExpression -> SearchExpression -> Bool
$c/= :: SearchExpression -> SearchExpression -> Bool
== :: SearchExpression -> SearchExpression -> Bool
$c== :: SearchExpression -> SearchExpression -> Bool
Prelude.Eq, ReadPrec [SearchExpression]
ReadPrec SearchExpression
Int -> ReadS SearchExpression
ReadS [SearchExpression]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchExpression]
$creadListPrec :: ReadPrec [SearchExpression]
readPrec :: ReadPrec SearchExpression
$creadPrec :: ReadPrec SearchExpression
readList :: ReadS [SearchExpression]
$creadList :: ReadS [SearchExpression]
readsPrec :: Int -> ReadS SearchExpression
$creadsPrec :: Int -> ReadS SearchExpression
Prelude.Read, Int -> SearchExpression -> ShowS
[SearchExpression] -> ShowS
SearchExpression -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchExpression] -> ShowS
$cshowList :: [SearchExpression] -> ShowS
show :: SearchExpression -> String
$cshow :: SearchExpression -> String
showsPrec :: Int -> SearchExpression -> ShowS
$cshowsPrec :: Int -> SearchExpression -> ShowS
Prelude.Show, forall x. Rep SearchExpression x -> SearchExpression
forall x. SearchExpression -> Rep SearchExpression x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchExpression x -> SearchExpression
$cfrom :: forall x. SearchExpression -> Rep SearchExpression x
Prelude.Generic)

-- |
-- Create a value of 'SearchExpression' 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:
--
-- 'filters', 'searchExpression_filters' - The search expression filters.
newSearchExpression ::
  SearchExpression
newSearchExpression :: SearchExpression
newSearchExpression =
  SearchExpression' {$sel:filters:SearchExpression' :: [Filter]
filters = forall a. Monoid a => a
Prelude.mempty}

-- | The search expression filters.
searchExpression_filters :: Lens.Lens' SearchExpression [Filter]
searchExpression_filters :: Lens' SearchExpression [Filter]
searchExpression_filters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchExpression' {[Filter]
filters :: [Filter]
$sel:filters:SearchExpression' :: SearchExpression -> [Filter]
filters} -> [Filter]
filters) (\s :: SearchExpression
s@SearchExpression' {} [Filter]
a -> SearchExpression
s {$sel:filters:SearchExpression' :: [Filter]
filters = [Filter]
a} :: SearchExpression) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable SearchExpression where
  hashWithSalt :: Int -> SearchExpression -> Int
hashWithSalt Int
_salt SearchExpression' {[Filter]
filters :: [Filter]
$sel:filters:SearchExpression' :: SearchExpression -> [Filter]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Filter]
filters

instance Prelude.NFData SearchExpression where
  rnf :: SearchExpression -> ()
rnf SearchExpression' {[Filter]
filters :: [Filter]
$sel:filters:SearchExpression' :: SearchExpression -> [Filter]
..} = forall a. NFData a => a -> ()
Prelude.rnf [Filter]
filters

instance Data.ToJSON SearchExpression where
  toJSON :: SearchExpression -> Value
toJSON SearchExpression' {[Filter]
filters :: [Filter]
$sel:filters:SearchExpression' :: SearchExpression -> [Filter]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"filters" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Filter]
filters)]
      )