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;
16 * This bean represents the information necessary to uniquely reference a widget on the LaMetric Time platform.
18 * @author Gregor Moyer - Initial contribution
20 public class WidgetRef {
21 private final String packageName;
22 private final String widgetId;
25 * Build a {@link WidgetRef} from the given String.
27 * @param widgetRef formatted as <code>package name:widget ID</code>
28 * @return the widget reference
30 public static WidgetRef fromString(String widgetRef) {
31 String[] tokens = widgetRef.split(":");
32 if (tokens.length != 2) {
33 throw new IllegalArgumentException(
34 "Provided string '" + widgetRef + "' is not in the format '<package name>:<widget ID>'");
37 return new WidgetRef(tokens[0], tokens[1]);
40 public WidgetRef(String packageName, String widgetId) {
41 this.packageName = packageName;
42 this.widgetId = widgetId;
45 public String getPackageName() {
49 public String getWidgetId() {
54 public String toString() {
55 return packageName + ":" + widgetId;