]> git.basschouten.com Git - openhab-addons.git/blob
b9228a17215bc8d965a68fbce4747b2788451485
[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.energidataservice.internal.api;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * Charge type code for DatahubPricelist dataset.
19  * See {@link https://www.energidataservice.dk/tso-electricity/DatahubPricelist#metadata-info}}
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  * @author Jacob Laursen - Initial contribution
24  */
25 @NonNullByDefault
26 public class ChargeTypeCode {
27
28     private static final int MAX_LENGTH = 20;
29
30     private final String code;
31
32     public ChargeTypeCode(String code) {
33         if (code.length() > MAX_LENGTH) {
34             throw new IllegalArgumentException("Maximum length exceeded: " + code);
35         }
36         this.code = code;
37     }
38
39     @Override
40     public String toString() {
41         return code;
42     }
43
44     public static ChargeTypeCode of(String code) {
45         return new ChargeTypeCode(code);
46     }
47 }