]> git.basschouten.com Git - openhab-addons.git/blob
08b1e2f82b7992aefb665cb59e8a8448a03b1ed8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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;
14
15 import static org.openhab.binding.bmwconnecteddrive.internal.utils.Constants.*;
16
17 import org.openhab.binding.bmwconnecteddrive.internal.utils.Constants;
18 import org.openhab.binding.bmwconnecteddrive.internal.utils.Converter;
19
20 /**
21  * The {@link Destination} Data Transfer Object
22  *
23  * @author Bernd Weymann - Initial contribution
24  */
25 public class Destination {
26     public float lat;
27     public float lon;
28     public String country;
29     public String city;
30     public String street;
31     public String streetNumber;
32     public String type;
33     public String createdAt;
34
35     public String getAddress() {
36         StringBuilder buf = new StringBuilder();
37         if (street != null) {
38             buf.append(street);
39             if (streetNumber != null) {
40                 buf.append(SPACE).append(streetNumber);
41             }
42         }
43         if (city != null) {
44             if (buf.length() > 0) {
45                 buf.append(COMMA).append(SPACE).append(city);
46             } else {
47                 buf.append(city);
48             }
49         }
50         if (buf.length() == 0) {
51             return UNDEF;
52         } else {
53             return Converter.toTitleCase(buf.toString());
54         }
55     }
56
57     public String getCoordinates() {
58         return lat + Constants.COMMA + lon;
59     }
60 }