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.lutron.internal.protocol.leap;
15 import java.util.regex.Matcher;
16 import java.util.regex.Pattern;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
23 * Abstract base class for LEAP message body objects
25 * @author Bob Adair - Initial contribution
28 public abstract class AbstractMessageBody {
31 * Utility method to extract the int from a href String using the supplied Pattern.
33 * @return the int or 0 if unable to extract
35 protected static int hrefNumber(Pattern pattern, @Nullable String href) {
39 Matcher matcher = pattern.matcher(href);
42 return Integer.parseInt(matcher.group(1));
43 } catch (NumberFormatException e) {