# Enum LockState

java.lang.Object
java.lang.Enum<LockState>
com.codename1.home.LockState

All Implemented Interfaces:
  `Comparable<LockState>`

public enum LockState extends Enum<LockState>

The state of a door lock, for `Trait.LOCK_STATE` and `Trait.TARGET_LOCK_STATE`.

Only `SECURED` and `UNSECURED` may be written; the rest describe situations an accessory reports and a caller cannot ask for.

- ## Enum Constant Summary

  Enum Constants
  Enum Constant
  Description
  `JAMMED`
  The mechanism is stuck.
  `PARTIALLY_LOCKED`
  The bolt is partly thrown: not locked, and not simply open either.
  `SECURED`
  Locked.
  `UNKNOWN`
  The accessory could not say.
  `UNSECURED`
  Unlocked.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `isWritable()`
  Whether this state may be written to `Trait.TARGET_LOCK_STATE`.
  `static LockState`
  `of(TraitValue value)`
  Reads a lock state out of a trait value, total: a value that is not an enum, or whose ordinal is outside this set, answers `UNKNOWN`.
  `static LockState`
  `valueOf(String name)`
  Returns the enum constant of this type with the specified name.
  `static LockState[]`
  `values()`
  Returns an array containing the constants of this enum type, in the order they are declared.

  ### Methods inherited from class Enum

  `clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name, ordinal, setEnumValues, toString, valueOf`

  ### Methods inherited from class Object

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

- ## Enum Constant Details

  - ### SECURED

    public static final LockState SECURED

    Locked.

    Maps to HomeKit's `secured` and Matter's `Locked`.

  - ### UNSECURED

    public static final LockState UNSECURED

    Unlocked.

    Maps to HomeKit's `unsecured` and to both of Matter's `Unlocked` and `Unlatched` -- the latter is a 1.4 addition meaning the latch has been pulled back as well as the bolt, which HomeKit has no way to say.

  - ### PARTIALLY_LOCKED

    public static final LockState PARTIALLY_LOCKED

    The bolt is partly thrown: not locked, and not simply open either.

    Matter's `NotFullyLocked`. Its own constant rather than being folded into a neighbour, because both alternatives lose real information -- calling it `JAMMED` asserts a fault that may not exist, and calling it `UNKNOWN` throws away a state the accessory was specific about.

    HomeKit never produces this.

  - ### JAMMED

    public static final LockState JAMMED

    The mechanism is stuck.

    Unreachable outside HomeKit. HomeKit publishes a jam as a value of the lock characteristic, so it arrives here. Matter reports it as a `LockOperationError` or `DoorLockAlarm` event, and this release does not claim Matter events -- so a jammed Matter lock reports `PARTIALLY_LOCKED` or `UNKNOWN` instead. Do not build a safety feature on this constant.

  - ### UNKNOWN

    public static final LockState UNKNOWN
    The accessory could not say. Also what a nullable Matter `LockState` resolves to when it is null.

- ## Method Details

  - ### values

    public static LockState[] values()
    Returns an array containing the constants of this enum type, in the order they are declared.
    Returns:
      an array containing the constants of this enum type, in the order they are declared

  - ### valueOf

    public static LockState 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

  - ### of

    public static LockState of(TraitValue value)

    Reads a lock state out of a trait value, total: a value that is not an enum, or whose ordinal is outside this set, answers `UNKNOWN`.

    ###### Parameters

    - `value`: a value read from `Trait.LOCK_STATE` or `Trait.TARGET_LOCK_STATE`, or `null`

    ###### Returns

    the state, never `null`

  - ### isWritable

    public boolean isWritable()

    Whether this state may be written to `Trait.TARGET_LOCK_STATE`.

    ###### Returns

    `true` for `SECURED` and `UNSECURED` only