]> git.basschouten.com Git - openhab-addons.git/blob
ad0f60a63b2c901d5fc7dd7f24dc1f1078325b27
[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.plugwise.internal.protocol.field;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * The media access control (MAC) address of a Plugwise device, e.g.: 000D6F0000A1B2C3
20  *
21  * @author Wouter Born - Initial contribution
22  */
23 @NonNullByDefault
24 public class MACAddress {
25
26     private final String macAddress;
27
28     public MACAddress(String macAddress) {
29         this.macAddress = macAddress.toUpperCase();
30     }
31
32     @Override
33     public int hashCode() {
34         final int prime = 31;
35         int result = 1;
36         result = prime * result + macAddress.hashCode();
37         return result;
38     }
39
40     @Override
41     public boolean equals(@Nullable Object obj) {
42         if (this == obj) {
43             return true;
44         }
45         if (obj == null) {
46             return false;
47         }
48         if (getClass() != obj.getClass()) {
49             return false;
50         }
51         MACAddress other = (MACAddress) obj;
52         if (!macAddress.equals(other.macAddress)) {
53             return false;
54         }
55         return true;
56     }
57
58     @Override
59     public String toString() {
60         return macAddress;
61     }
62 }