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.siemensrds.points;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.library.types.DecimalType;
18 import org.openhab.core.types.State;
20 import com.google.gson.annotations.SerializedName;
23 * private class a data point where "value" is a JSON numeric element
25 * @author Andrew Fiddian-Green - Initial contribution
29 public class NumberPoint extends BasePoint {
31 @SerializedName("value")
32 private @Nullable Number value;
36 Number value = this.value;
37 return value != null ? value.intValue() : UNDEFINED_VALUE;
41 public State getState() {
42 Number value = this.value;
43 return value != null ? new DecimalType(value.doubleValue()) : new DecimalType(UNDEFINED_VALUE);
47 public void refreshValueFrom(BasePoint from) {
48 super.refreshValueFrom(from);
49 if (from instanceof NumberPoint) {
50 this.value = ((NumberPoint) from).value;