2 * Copyright (c) 2010-2023 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.
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".
23 * @author Jacob Laursen - Initial contribution
26 public class ChargeTypeCode {
28 private static final int MAX_LENGTH = 20;
30 private final String code;
32 public ChargeTypeCode(String code) {
33 if (code.length() > MAX_LENGTH) {
34 throw new IllegalArgumentException("Maximum length exceeded: " + code);
40 public String toString() {
44 public static ChargeTypeCode of(String code) {
45 return new ChargeTypeCode(code);