]> git.basschouten.com Git - openhab-addons.git/blob
14e127ae30a94dd8618a086c3616985dbdd415bf
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.bmwconnecteddrive.internal.dto.status;
14
15 import org.openhab.binding.bmwconnecteddrive.internal.utils.Constants;
16 import org.openhab.binding.bmwconnecteddrive.internal.utils.Converter;
17
18 /**
19  * The {@link CBSMessage} Data Transfer Object
20  *
21  * @author Bernd Weymann - Initial contribution
22  */
23 public class CBSMessage {
24     public String cbsType;// ": "BRAKE_FLUID",
25     public String cbsState;// ": "OK",
26     public String cbsDueDate;// ": "2021-11",
27     public String cbsDescription;// ": "Next change due at the latest by the stated date."
28     public int cbsRemainingMileage = -1; // 46000
29
30     public String cbsTypeConverted = null;
31     public String cbsDescriptionConverted = null;
32
33     public String getDueDate() {
34         if (cbsDueDate == null) {
35             return Constants.NULL_DATE;
36         } else {
37             return cbsDueDate + Constants.UTC_APPENDIX;
38         }
39     }
40
41     public String getType() {
42         if (cbsTypeConverted == null) {
43             if (cbsType == null) {
44                 cbsTypeConverted = Constants.INVALID;
45             } else {
46                 cbsTypeConverted = Converter.toTitleCase(cbsType);
47             }
48         }
49         return cbsTypeConverted;
50     }
51
52     public String getDescription() {
53         if (cbsDescriptionConverted == null) {
54             if (cbsDescription == null) {
55                 cbsDescriptionConverted = Constants.INVALID;
56             } else {
57                 cbsDescriptionConverted = cbsDescription;
58             }
59         }
60         return cbsDescriptionConverted;
61     }
62
63     @Override
64     public String toString() {
65         return new StringBuilder(cbsDueDate).append(Constants.HYPHEN).append(cbsRemainingMileage)
66                 .append(Constants.HYPHEN).append(cbsType).toString();
67     }
68 }