liblldp: final parameters
[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     protected DataLinkAddress(final String name) {
42         this.name = name;
43     }
44
45     /**
46      * Used to copy the DataLinkAddress in a polymorphic way
47      *
48      *
49      * @return A clone of this DataLinkAddress
50      */
51     @Override
52     abstract public DataLinkAddress clone();
53
54     /**
55      * Allow to distinguish among different data link addresses
56      *
57      *
58      * @return Name of the DataLinkAdress we are working on
59      */
60     public String getName() {
61         return this.name;
62     }
63
64     @Override
65     public int hashCode() {
66         final int prime = 31;
67         int result = 1;
68         result = prime * result + ((name == null) ? 0 : name.hashCode());
69         return result;
70     }
71
72     @Override
73     public boolean equals(final Object obj) {
74         if (this == obj) {
75             return true;
76         }
77         if (obj == null) {
78             return false;
79         }
80         if (getClass() != obj.getClass()) {
81             return false;
82         }
83         DataLinkAddress other = (DataLinkAddress) obj;
84         if (name == null) {
85             if (other.name != null) {
86                 return false;
87             }
88         } else if (!name.equals(other.name)) {
89             return false;
90         }
91         return true;
92     }
93
94     @Override
95     public String toString() {
96         return "DataLinkAddress [name=" + name + "]";
97     }
98 }