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.lametrictime.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * This bean represents the information necessary to uniquely reference a widget on the LaMetric Time platform.
20 * @author Gregor Moyer - Initial contribution
23 public class WidgetRef {
24 private final String packageName;
25 private final String widgetId;
28 * Build a {@link WidgetRef} from the given String.
30 * @param widgetRef formatted as <code>package name:widget ID</code>
31 * @return the widget reference
33 public static WidgetRef fromString(String widgetRef) {
34 String[] tokens = widgetRef.split(":");
35 if (tokens.length != 2) {
36 throw new IllegalArgumentException(
37 "Provided string '" + widgetRef + "' is not in the format '<package name>:<widget ID>'");
40 return new WidgetRef(tokens[0], tokens[1]);
43 public WidgetRef(String packageName, String widgetId) {
44 this.packageName = packageName;
45 this.widgetId = widgetId;
48 public String getPackageName() {
52 public String getWidgetId() {
57 public String toString() {
58 return packageName + ":" + widgetId;