2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.sal.core;
11 import java.util.Arrays;
13 import javax.xml.bind.annotation.XmlAccessType;
14 import javax.xml.bind.annotation.XmlAccessorType;
15 import javax.xml.bind.annotation.XmlElement;
16 import javax.xml.bind.annotation.XmlRootElement;
18 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
21 * The class contains MAC address property.
24 @XmlAccessorType(XmlAccessType.NONE)
25 public class MacAddress extends Property implements Cloneable {
26 private static final long serialVersionUID = 1L;
27 @XmlElement(name="macAddress")
28 private final byte[] address;
29 public static final String name = "macAddress";
32 * Private constructor used for JAXB mapping
34 private MacAddress() {
40 * Constructor to create DatalinkAddress property which contains the MAC
41 * address. The property will be attached to a
42 * {@link org.opendaylight.controller.sal.core.Node}.
45 * @param nodeMacAddress
46 * Data Link Address for the node
48 * @return the constructed object
50 public MacAddress(byte[] nodeMacAddress) {
52 this.address = nodeMacAddress.clone();
56 * @return the node MAC address
58 public byte[] getMacAddress() {
59 return this.address.clone();
63 public MacAddress clone() {
64 return new MacAddress(this.address);
68 public int hashCode() {
70 int result = super.hashCode();
71 result = prime * result + Arrays.hashCode(address);
76 public boolean equals(Object obj) {
80 if (!super.equals(obj)) {
83 if (getClass() != obj.getClass()) {
86 MacAddress other = (MacAddress) obj;
87 if (!Arrays.equals(address, other.address)) {
94 public String toString() {
95 return "MacAddress[" + ReflectionToStringBuilder.toString(this) + "]";