Fix license header violations in liblldp
[controller.git] / opendaylight / commons / liblldp / src / main / java / org / opendaylight / controller / liblldp / DataLinkAddress.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.liblldp;
10
11 import java.io.Serializable;
12
13 import javax.xml.bind.annotation.XmlRootElement;
14
15 /**
16  * @file   DataLinkAddress.java
17  *
18  * @brief  Abstract base class for a Datalink Address
19  *
20  */
21
22 /**
23  * Abstract base class for a Datalink Address
24  *
25  */
26 @XmlRootElement
27 abstract public class DataLinkAddress implements Serializable {
28     private static final long serialVersionUID = 1L;
29     private String name;
30
31     public DataLinkAddress() {
32
33     }
34
35     /**
36      * Constructor of super class
37      *
38      * @param name Create a new DataLink, not for general use but
39      * available only for sub classes
40      *
41      * @return constructed object
42      */
43     protected DataLinkAddress(String name) {
44         this.name = name;
45     }
46
47     /**
48      * Used to copy the DataLinkAddress in a polymorphic way
49      *
50      *
51      * @return A clone of this DataLinkAddress
52      */
53     @Override
54     abstract public DataLinkAddress clone();
55
56     /**
57      * Allow to distinguish among different data link addresses
58      *
59      *
60      * @return Name of the DataLinkAdress we are working on
61      */
62     public String getName() {
63         return this.name;
64     }
65
66     @Override
67     public int hashCode() {
68         final int prime = 31;
69         int result = 1;
70         result = prime * result + ((name == null) ? 0 : name.hashCode());
71         return result;
72     }
73
74     @Override
75     public boolean equals(Object obj) {
76         if (this == obj) {
77             return true;
78         }
79         if (obj == null) {
80             return false;
81         }
82         if (getClass() != obj.getClass()) {
83             return false;
84         }
85         DataLinkAddress other = (DataLinkAddress) obj;
86         if (name == null) {
87             if (other.name != null) {
88                 return false;
89             }
90         } else if (!name.equals(other.name)) {
91             return false;
92         }
93         return true;
94     }
95
96     @Override
97     public String toString() {
98         return "DataLinkAddress [name=" + name + "]";
99     }
100 }