Make sure PCEPMessageHeader is threadsafe
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / PCEPSessionPreferences.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 package org.opendaylight.protocol.pcep;
9
10 import org.opendaylight.protocol.framework.SessionPreferences;
11 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
12
13 /**
14  * Implementation of {@link SessionPreferences}.
15  */
16 public final class PCEPSessionPreferences implements SessionPreferences {
17
18         private final PCEPOpenObject openObject;
19
20         /**
21          * Construct new session preferences.
22          *
23          * @param openObject encapsulated PCEP OPEN object
24          */
25         public PCEPSessionPreferences(final PCEPOpenObject openObject) {
26                 this.openObject = openObject;
27         }
28
29         /**
30          * Return the encapsulated OPEN object.
31          *
32          * @return encapsulated OPEN object.
33          */
34         public PCEPOpenObject getOpenObject() {
35                 return this.openObject;
36         }
37
38         @Override
39         public int hashCode() {
40                 final int prime = 31;
41                 int result = 1;
42                 result = prime * result
43                                 + ((this.openObject == null) ? 0 : this.openObject.hashCode());
44                 return result;
45         }
46
47         @Override
48         public boolean equals(Object obj) {
49                 if (this == obj)
50                         return true;
51                 if (obj == null)
52                         return false;
53                 if (!(obj instanceof PCEPSessionPreferences))
54                         return false;
55                 final PCEPSessionPreferences other = (PCEPSessionPreferences) obj;
56                 if (this.openObject == null) {
57                         if (other.openObject != null)
58                                 return false;
59                 } else if (!this.openObject.equals(other.openObject))
60                         return false;
61                 return true;
62         }
63 }