]> git.basschouten.com Git - openhab-addons.git/blob
7a8fd2639c13a5497bede6f7d6bcdc42ff36cc55
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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     @SuppressWarnings("PMD.SimplifyBooleanReturns")
41     @Override
42     public boolean equals(@Nullable Object obj) {
43         if (this == obj) {
44             return true;
45         }
46         if (obj == null) {
47             return false;
48         }
49         if (getClass() != obj.getClass()) {
50             return false;
51         }
52         MACAddress other = (MACAddress) obj;
53         if (!macAddress.equals(other.macAddress)) {
54             return false;
55         }
56         return true;
57     }
58
59     @Override
60     public String toString() {
61         return macAddress;
62     }
63 }