2 * Copyright (c) 2010-2024 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.insteon.internal.transport.message;
15 import java.util.Arrays;
17 import java.util.function.Function;
18 import java.util.stream.Collectors;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
23 * Defines the data types that can be used in the fields of a message.
25 * @author Daniel Pfrommer - Initial contribution
26 * @author Rob Nielsen - Port to openHAB 2 insteon binding
27 * @author Jeremy Setton - Rewrite insteon binding
30 public enum DataType {
32 ADDRESS("address", 3),
33 INVALID("invalid", -1);
35 private static final Map<String, DataType> NAME_MAP = Arrays.stream(values())
36 .collect(Collectors.toUnmodifiableMap(type -> type.name, Function.identity()));
38 private final String name;
39 private final int size;
41 private DataType(String name, int size) {
46 public String getName() {
50 public int getSize() {
55 * Factory method for getting a DataType from the data type name
57 * @param name the data type name
58 * @return the data type
60 public static DataType get(String name) {
61 return NAME_MAP.getOrDefault(name, DataType.INVALID);