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
8 package org.opendaylight.protocol.pcep.object;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.protocol.pcep.PCEPObject;
14 import org.opendaylight.protocol.pcep.PCEPTlv;
15 import com.google.common.base.Objects.ToStringHelper;
18 * Structure of PCEP Open Object.
20 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.3">PCEP Open
23 public class PCEPOpenObject extends PCEPObject {
25 public static final int PCEP_VERSION = 1;
27 private final int keepAliveTimerValue;
29 private final int deadTimerValue;
31 private final int sessionId;
33 private final List<PCEPTlv> tlvs;
36 * Constructs PCEP Open Object also with optional Objects.
38 * @param keepAliveTimerValue
40 * @param deadTimerValue
47 public PCEPOpenObject(int keepAliveTimerValue, int deadTimerValue, int sessionId, List<PCEPTlv> tlvs) {
49 this.keepAliveTimerValue = keepAliveTimerValue;
50 this.deadTimerValue = deadTimerValue;
51 this.sessionId = sessionId;
55 this.tlvs = Collections.emptyList();
59 * Constructs PCEP Open Object only with mandatory values.
61 * @param keepAliveTimerValue
63 * @param deadTimerValue
68 public PCEPOpenObject(int keepAliveTimerValue, int deadTimerValue, int sessionId) {
69 this(keepAliveTimerValue, deadTimerValue, sessionId, Collections.<PCEPTlv> emptyList());
73 * Returns integer representation of Keep Alive Timer.
77 public int getKeepAliveTimerValue() {
78 return this.keepAliveTimerValue;
82 * Returns integer representation of Dead Timer.
86 public int getDeadTimerValue() {
87 return this.deadTimerValue;
91 * Returns integer representation of Session ID.
95 public int getSessionId() {
96 return this.sessionId;
100 * Gets list of {@link PCEPTlv}.
102 * @return List<PCEPTlv>
104 public List<PCEPTlv> getTlvs() {
109 public int hashCode() {
110 final int prime = 31;
112 result = prime * result + this.deadTimerValue;
113 result = prime * result + this.keepAliveTimerValue;
114 result = prime * result + this.sessionId;
115 result = prime * result + ((this.tlvs == null) ? 0 : this.tlvs.hashCode());
120 public boolean equals(Object obj) {
125 if (this.getClass() != obj.getClass())
127 final PCEPOpenObject other = (PCEPOpenObject) obj;
128 if (this.deadTimerValue != other.deadTimerValue)
130 if (this.keepAliveTimerValue != other.keepAliveTimerValue)
132 if (this.sessionId != other.sessionId)
134 if (this.tlvs == null) {
135 if (other.tlvs != null)
137 } else if (!this.tlvs.equals(other.tlvs))
143 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
144 toStringHelper.add("keepAliveTimerValue", this.keepAliveTimerValue);
145 toStringHelper.add("deadTimerValue", this.deadTimerValue);
146 toStringHelper.add("sessionId", this.sessionId);
147 toStringHelper.add("tlvs", this.tlvs);
148 return super.addToStringAttributes(toStringHelper);