2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.mielecloud.internal.webservice.api.json;
15 import java.util.Collections;
16 import java.util.HashMap;
18 import java.util.Optional;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
23 * Represents the Miele device state.
25 * @author Roland Edelhoff - Initial contribution
28 public enum StateType {
32 PROGRAMMED_WAITING_TO_START(4),
37 PROGRAMME_INTERRUPTED(9),
44 SUPERCOOLING_SUPERFREEZING(146),
47 private static final Map<Integer, StateType> STATE_TYPE_BY_CODE;
50 Map<Integer, StateType> stateTypeByCode = new HashMap<>();
51 for (StateType stateType : values()) {
52 stateTypeByCode.put(stateType.code, stateType);
54 STATE_TYPE_BY_CODE = Collections.unmodifiableMap(stateTypeByCode);
57 private final int code;
59 private StateType(int code) {
63 public int getCode() {
67 public static Optional<StateType> fromCode(int code) {
68 return Optional.ofNullable(STATE_TYPE_BY_CODE.get(code));