]> git.basschouten.com Git - openhab-addons.git/blob
c6aed5c9041d973d76b791ecab75a03dd5b86c96
[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.energidataservice.internal.api;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * Charge type code for DatahubPricelist dataset.
19  *
20  * These codes are defined by the individual grid companies.
21  * For example, N1 uses "CD" for "Nettarif C" and "CD R" for "Rabat på nettarif N1 A/S".
22  *
23  * @see <a href="https://www.energidataservice.dk/tso-electricity/DatahubPricelist#metadata-info">
24  *      https://www.energidataservice.dk/tso-electricity/DatahubPricelist#metadata-info</a>
25  * @author Jacob Laursen - Initial contribution
26  */
27 @NonNullByDefault
28 public class ChargeTypeCode {
29
30     private static final int MAX_LENGTH = 20;
31
32     private final String code;
33
34     public ChargeTypeCode(String code) {
35         if (code.length() > MAX_LENGTH) {
36             throw new IllegalArgumentException("Maximum length exceeded: " + code);
37         }
38         this.code = code;
39     }
40
41     @Override
42     public String toString() {
43         return code;
44     }
45
46     public static ChargeTypeCode of(String code) {
47         return new ChargeTypeCode(code);
48     }
49 }