{-# 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.DeviceFarm.Types.Resolution
-- 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.DeviceFarm.Types.Resolution where

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

-- | Represents the screen resolution of a device in height and width,
-- expressed in pixels.
--
-- /See:/ 'newResolution' smart constructor.
data Resolution = Resolution'
  { -- | The screen resolution\'s height, expressed in pixels.
    Resolution -> Maybe Int
height :: Prelude.Maybe Prelude.Int,
    -- | The screen resolution\'s width, expressed in pixels.
    Resolution -> Maybe Int
width :: Prelude.Maybe Prelude.Int
  }
  deriving (Resolution -> Resolution -> Bool
(Resolution -> Resolution -> Bool)
-> (Resolution -> Resolution -> Bool) -> Eq Resolution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Resolution -> Resolution -> Bool
$c/= :: Resolution -> Resolution -> Bool
== :: Resolution -> Resolution -> Bool
$c== :: Resolution -> Resolution -> Bool
Prelude.Eq, ReadPrec [Resolution]
ReadPrec Resolution
Int -> ReadS Resolution
ReadS [Resolution]
(Int -> ReadS Resolution)
-> ReadS [Resolution]
-> ReadPrec Resolution
-> ReadPrec [Resolution]
-> Read Resolution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Resolution]
$creadListPrec :: ReadPrec [Resolution]
readPrec :: ReadPrec Resolution
$creadPrec :: ReadPrec Resolution
readList :: ReadS [Resolution]
$creadList :: ReadS [Resolution]
readsPrec :: Int -> ReadS Resolution
$creadsPrec :: Int -> ReadS Resolution
Prelude.Read, Int -> Resolution -> ShowS
[Resolution] -> ShowS
Resolution -> String
(Int -> Resolution -> ShowS)
-> (Resolution -> String)
-> ([Resolution] -> ShowS)
-> Show Resolution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Resolution] -> ShowS
$cshowList :: [Resolution] -> ShowS
show :: Resolution -> String
$cshow :: Resolution -> String
showsPrec :: Int -> Resolution -> ShowS
$cshowsPrec :: Int -> Resolution -> ShowS
Prelude.Show, (forall x. Resolution -> Rep Resolution x)
-> (forall x. Rep Resolution x -> Resolution) -> Generic Resolution
forall x. Rep Resolution x -> Resolution
forall x. Resolution -> Rep Resolution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Resolution x -> Resolution
$cfrom :: forall x. Resolution -> Rep Resolution x
Prelude.Generic)

-- |
-- Create a value of 'Resolution' 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:
--
-- 'height', 'resolution_height' - The screen resolution\'s height, expressed in pixels.
--
-- 'width', 'resolution_width' - The screen resolution\'s width, expressed in pixels.
newResolution ::
  Resolution
newResolution :: Resolution
newResolution =
  Resolution' :: Maybe Int -> Maybe Int -> Resolution
Resolution'
    { $sel:height:Resolution' :: Maybe Int
height = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:width:Resolution' :: Maybe Int
width = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The screen resolution\'s height, expressed in pixels.
resolution_height :: Lens.Lens' Resolution (Prelude.Maybe Prelude.Int)
resolution_height :: (Maybe Int -> f (Maybe Int)) -> Resolution -> f Resolution
resolution_height = (Resolution -> Maybe Int)
-> (Resolution -> Maybe Int -> Resolution)
-> Lens Resolution Resolution (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resolution' {Maybe Int
height :: Maybe Int
$sel:height:Resolution' :: Resolution -> Maybe Int
height} -> Maybe Int
height) (\s :: Resolution
s@Resolution' {} Maybe Int
a -> Resolution
s {$sel:height:Resolution' :: Maybe Int
height = Maybe Int
a} :: Resolution)

-- | The screen resolution\'s width, expressed in pixels.
resolution_width :: Lens.Lens' Resolution (Prelude.Maybe Prelude.Int)
resolution_width :: (Maybe Int -> f (Maybe Int)) -> Resolution -> f Resolution
resolution_width = (Resolution -> Maybe Int)
-> (Resolution -> Maybe Int -> Resolution)
-> Lens Resolution Resolution (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resolution' {Maybe Int
width :: Maybe Int
$sel:width:Resolution' :: Resolution -> Maybe Int
width} -> Maybe Int
width) (\s :: Resolution
s@Resolution' {} Maybe Int
a -> Resolution
s {$sel:width:Resolution' :: Maybe Int
width = Maybe Int
a} :: Resolution)

instance Core.FromJSON Resolution where
  parseJSON :: Value -> Parser Resolution
parseJSON =
    String
-> (Object -> Parser Resolution) -> Value -> Parser Resolution
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Resolution"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> Resolution
Resolution'
            (Maybe Int -> Maybe Int -> Resolution)
-> Parser (Maybe Int) -> Parser (Maybe Int -> Resolution)
forall (f :: * -> *) a b. Functor 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
"height")
            Parser (Maybe Int -> Resolution)
-> Parser (Maybe Int) -> Parser Resolution
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
"width")
      )

instance Prelude.Hashable Resolution

instance Prelude.NFData Resolution