com.holonplatform.vaadin.flow.device

## Interface DeviceInfo

- All Superinterfaces:
    Serializable, UserAgentInspector

      public interface DeviceInfo
      extends UserAgentInspector

  Provides informations about the client device in which application is running.
  Since:
    5.2.0
  See Also:
    `UserAgentInspector`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SESSION_ATTRIBUTE_NAME` Name of the session attribute to cache DeviceInfo instance

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DeviceInfo` | `create(com.vaadin.flow.component.UI ui, UserAgentInspector userAgentInspector)` Create a new `DeviceInfo` for given UI, using the provided `UserAgentInspector`.
    `static DeviceInfo` | `create(com.vaadin.flow.component.UI ui, com.vaadin.flow.server.VaadinRequest request)` Create a new `DeviceInfo` for given UI, using the provided `VaadinRequest` to configure a default `UserAgentInspector`.
    `static Optional<DeviceInfo>` | `get()` Get the `DeviceInfo` for the current UI, if available.
    `static Optional<DeviceInfo>` | `get(com.vaadin.flow.component.UI ui)` Get the `DeviceInfo` for given UI, if available.
    `int` | `getWindowHeight()` Get the browser window height.
    `int` | `getWindowWidth()` Get the browser window width.
    `static DeviceInfo` | `require()` Get the `DeviceInfo` for the current UI, throwing a `IllegalStateException` if not available.

    - ### Methods inherited from interface com.holonplatform.vaadin.flow.device.UserAgentInspector

      `create, create, getAcceptHeader, getUserAgentHeader, isAndroid, isAndroidPhone, isAndroidTablet, isGameConsole, isIOs, isIPad, isIPhone, isIPod, isKindle, isMobile, isNintendo, isPlaystation, isSmartphone, isTablet, isWebKit, isWindowsPhone, isXbox`

- - ### Field Detail

    - #### SESSION_ATTRIBUTE_NAME

          static final String SESSION_ATTRIBUTE_NAME

      Name of the session attribute to cache DeviceInfo instance

  - ### Method Detail

    - #### getWindowWidth

          int getWindowWidth()

      Get the browser window width.
      Returns:
        the browser window width in pixels, or `-1` if not available at method call time

    - #### getWindowHeight

          int getWindowHeight()

      Get the browser window height.
      Returns:
        the browser window height in pixels, or `-1` if not available at method call time

    - #### get

          static Optional<DeviceInfo> get(com.vaadin.flow.component.UI ui)

      Get the `DeviceInfo` for given UI, if available.
      Parameters:
        `ui` - The UI for which to obtain the `DeviceInfo` (not null)
      Returns:
        Optional `DeviceInfo` for given UI

    - #### get

          static Optional<DeviceInfo> get()

      Get the `DeviceInfo` for the current UI, if available.
      Returns:
        Optional `DeviceInfo` for the current UI

    - #### require

          static DeviceInfo require()

      Get the `DeviceInfo` for the current UI, throwing a `IllegalStateException` if not available.
      Returns:
        The `DeviceInfo` for the current UI
      Throws:
        `IllegalStateException` - If a DeviceInfo for current UI is not available

    - #### create

          static DeviceInfo create(com.vaadin.flow.component.UI ui,
                                   UserAgentInspector userAgentInspector)

      Create a new `DeviceInfo` for given UI, using the provided `UserAgentInspector`.
      Parameters:
        `ui` - The UI
        `userAgentInspector` - The `UserAgentInspector` to use (not null)
      Returns:
        A new `DeviceInfo`

    - #### create

          static DeviceInfo create(com.vaadin.flow.component.UI ui,
                                   com.vaadin.flow.server.VaadinRequest request)

      Create a new `DeviceInfo` for given UI, using the provided `VaadinRequest` to configure a default `UserAgentInspector`.
      Parameters:
        `ui` - The UI
        `request` - The request (not null)
      Returns:
        A new `DeviceInfo`

Copyright © 2019 The Holon Platform. All rights reserved.