2 * Copyright (c) 2010-2024 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.energidataservice.internal.api;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * Charge type code for DatahubPricelist dataset.
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".
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
28 public class ChargeTypeCode {
30 private static final int MAX_LENGTH = 20;
32 private final String code;
34 public ChargeTypeCode(String code) {
35 if (code.length() > MAX_LENGTH) {
36 throw new IllegalArgumentException("Maximum length exceeded: " + code);
42 public String toString() {
46 public static ChargeTypeCode of(String code) {
47 return new ChargeTypeCode(code);