]> git.basschouten.com Git - openhab-addons.git/blob
fc37dc629130912b0d574dec2c5f7c867f6ac9f8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.awattar.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.awattar.internal.handler.TimeRange;
17
18 /**
19  * Class to store hourly price data.
20  *
21  * @author Wolfgang Klimt - initial contribution
22  * @author Jan N. Klug - Refactored to record
23  */
24 @NonNullByDefault
25 public record AwattarPrice(double netPrice, double grossPrice, double netTotal, double grossTotal,
26         TimeRange timerange) implements Comparable<AwattarPrice> {
27
28     @Override
29     public String toString() {
30         return String.format("(%1$tF %1$tR - %2$tR: %3$.3f)", timerange.start(), timerange.end(), netPrice);
31     }
32
33     @Override
34     public int compareTo(AwattarPrice o) {
35         return Double.compare(netPrice, o.netPrice);
36     }
37 }