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