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.mybmw.internal.utils;
15 import java.util.List;
17 import java.util.Optional;
18 import java.util.stream.Collectors;
19 import java.util.stream.Stream;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.openhab.binding.mybmw.internal.handler.RemoteServiceHandler.RemoteService;
23 import org.openhab.core.types.CommandOption;
26 * Helper class for Remote Service Commands
28 * @author Norbert Truchsess - Initial contribution
31 public class RemoteServiceUtils {
33 private static final Map<String, RemoteService> COMMAND_SERVICES = Stream.of(RemoteService.values())
34 .collect(Collectors.toUnmodifiableMap(RemoteService::getId, service -> service));
36 public static Optional<RemoteService> getRemoteService(final String command) {
37 return Optional.ofNullable(COMMAND_SERVICES.get(command));
40 public static List<CommandOption> getOptions(final boolean isElectric) {
41 return Stream.of(RemoteService.values()).map(service -> new CommandOption(service.getId(), service.getLabel()))
42 .collect(Collectors.toUnmodifiableList());