]> git.basschouten.com Git - openhab-addons.git/blob
7a1b88eba66fd1f7abd2019eb504d9d594fd7b0e
[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.netatmo.internal.camera;
14
15 import java.util.Objects;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19
20 /**
21  * {@link CameraAddress} handles the data to address a camera (VPN and local address).
22  *
23  * @author Sven Strohschein - Initial contribution
24  */
25 @NonNullByDefault
26 public class CameraAddress {
27
28     private final String vpnURL;
29     private final String localURL;
30
31     CameraAddress(final String vpnURL, final String localURL) {
32         this.vpnURL = vpnURL;
33         this.localURL = localURL;
34     }
35
36     public String getVpnURL() {
37         return vpnURL;
38     }
39
40     public String getLocalURL() {
41         return localURL;
42     }
43
44     /**
45      * Checks if the VPN URL was changed / isn't equal to the given VPN-URL.
46      * 
47      * @param vpnURL old / known VPN URL
48      * @return true, when the VPN URL isn't equal given VPN URL, otherwise false
49      */
50     public boolean isVpnURLChanged(String vpnURL) {
51         return !getVpnURL().equals(vpnURL);
52     }
53
54     @Override
55     public boolean equals(@Nullable Object object) {
56         if (this == object) {
57             return true;
58         }
59         if (object == null || getClass() != object.getClass()) {
60             return false;
61         }
62         CameraAddress that = (CameraAddress) object;
63         return vpnURL.equals(that.vpnURL) && localURL.equals(that.localURL);
64     }
65
66     @Override
67     public int hashCode() {
68         return Objects.hash(vpnURL, localURL);
69     }
70 }