com.holonplatform.vaadin.flow.components.support

## Enum Unit

- java.lang.Object
- - java.lang.Enum<Unit>
  - - com.holonplatform.vaadin.flow.components.support.Unit

- All Implemented Interfaces:
    Serializable, Comparable<Unit>

      public enum Unit
      extends Enum<Unit>

  Component size units enumeration.

  Mainly intended as a replacement for the Vaadin 7/8 Sizeable.Unit class to ensure API backward compatibility.

  Since:
    5.2.0

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `CM` Unit code representing centimeters.
    `EM` Unit code representing the font-size of the relevant font.
    `EX` Unit code representing the x-height of the relevant font.
    `INCH` Unit code representing inches.
    `MM` Unit code representing millimeters.
    `PERCENTAGE` Unit code representing in percentage of the containing element defined by terminal.
    `PICAS` Unit code representing picas (12 points).
    `PIXELS` Unit code representing pixels.
    `POINTS` Unit code representing points (1/72nd of an inch).
    `REM` Unit code representing the font-size of the root font.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getSymbol()` Get the unit symbol.
    `static Optional<Unit>` | `getUnitFromSymbol(String symbol)` Get the `Unit` which corresponds to given symbol, if available.
    `static Unit` | `orDefault(Unit unit)` Get the given unit or the default one (Unit`PIXELS`) if `null`.
    `static String` | `sizeToString(float size)` Get the `String` representation of given size.
    `String` | `toString()`
    `static Unit` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static Unit[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `compareTo, equals, getDeclaringClass, hashCode, name, ordinal, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### PIXELS

          public static final Unit PIXELS

      Unit code representing pixels.

    - #### POINTS

          public static final Unit POINTS

      Unit code representing points (1/72nd of an inch).

    - #### PICAS

          public static final Unit PICAS

      Unit code representing picas (12 points).

    - #### EM

          public static final Unit EM

      Unit code representing the font-size of the relevant font.

    - #### REM

          public static final Unit REM

      Unit code representing the font-size of the root font.

    - #### EX

          public static final Unit EX

      Unit code representing the x-height of the relevant font.

    - #### MM

          public static final Unit MM

      Unit code representing millimeters.

    - #### CM

          public static final Unit CM

      Unit code representing centimeters.

    - #### INCH

          public static final Unit INCH

      Unit code representing inches.

    - #### PERCENTAGE

          public static final Unit PERCENTAGE

      Unit code representing in percentage of the containing element defined by terminal.

  - ### Method Detail

    - #### values

          public static Unit[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (Unit c : Unit.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static Unit valueOf(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### getSymbol

          public String getSymbol()

      Get the unit symbol.
      Returns:
        The unit symbol

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Enum<Unit>`

    - #### orDefault

          public static Unit orDefault(Unit unit)

      Get the given unit or the default one (Unit`PIXELS`) if `null`.
      Parameters:
        `unit` - The unit
      Returns:
        The given unit or the default one (Unit`PIXELS`) if `null`

    - #### getUnitFromSymbol

          public static Optional<Unit> getUnitFromSymbol(String symbol)

      Get the `Unit` which corresponds to given symbol, if available.
      Parameters:
        `symbol` - Unit symbol (may be null)
      Returns:
        Optional `Unit` which corresponds to given symbol

    - #### sizeToString

          public static String sizeToString(float size)

      Get the `String` representation of given size.
      Parameters:
        `size` - Size
      Returns:
        String representation

Copyright © 2019 The Holon Platform. All rights reserved.