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.heos.internal.json.dto;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * Tuple to contain a command group and command enum, this represents the full command send to / received by the HEOS
24 * @author Martin van Wingerden - Initial contribution
27 public class HeosCommandTuple {
28 private static final Logger LOGGER = LoggerFactory.getLogger(HeosCommandTuple.class);
30 public final HeosCommandGroup commandGroup;
31 public final HeosCommand command;
33 public HeosCommandTuple(HeosCommandGroup commandGroup, HeosCommand command) {
34 this.commandGroup = commandGroup;
35 this.command = command;
39 public static HeosCommandTuple valueOf(String commandString) {
40 String[] split = commandString.split("/");
42 if (split.length != 2) {
47 HeosCommandGroup group = HeosCommandGroup.valueOf(split[0].toUpperCase());
48 HeosCommand cmd = HeosCommand.valueOf(split[1].toUpperCase());
49 return new HeosCommandTuple(group, cmd);
50 } catch (IllegalArgumentException e) {
51 LOGGER.debug("Unsupported command {}", commandString);
57 public String toString() {
58 return commandGroup + "/" + command;