]> git.basschouten.com Git - openhab-addons.git/blob
1d27cab861918ca04725773589e51b68fc2b8200
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.fmiweather.internal.client;
14
15 import java.math.BigDecimal;
16 import java.util.Arrays;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * Simple class for numeric holding data
23  *
24  * @author Sami Salonen - Initial contribution
25  *
26  */
27 @NonNullByDefault
28 public class Data {
29
30     /**
31      * Array of timestamps, as epoch seconds
32      */
33     public final long[] timestampsEpochSecs;
34
35     /**
36      * Array of values, some of which may be null when value is not present.
37      */
38     public final @Nullable BigDecimal[] values;
39
40     /**
41      *
42      * @param timestampsEpochSecs
43      * @param values
44      * @throws IllegalArgumentException if length of timestampsEpochSecs and values do not match
45      */
46     public Data(long[] timestampsEpochSecs, BigDecimal[] values) {
47         if (timestampsEpochSecs.length != values.length) {
48             throw new IllegalArgumentException("length of arguments do not match");
49         }
50         this.timestampsEpochSecs = timestampsEpochSecs;
51         this.values = values;
52     }
53
54     @Override
55     public String toString() {
56         return new StringBuilder("ResponseDataValues(timestampsEpochSecs=").append(Arrays.toString(timestampsEpochSecs))
57                 .append(", values=").append(Arrays.deepToString(values)).append(")").toString();
58     }
59 }