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 Close Object.
20 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.17">PCEP Close
23 public class PCEPCloseObject extends PCEPObject {
26 * Constants for reasons of closing session.
29 UNKNOWN, EXP_DEADTIMER, MALFORMED_MSG, TOO_MANY_UNKNOWN_REQ_REP, TOO_MANY_UNKNOWN_MSG
32 private final Reason reason;
34 private List<PCEPTlv> tlvs;
37 * Constructs Close Object only with mandatory object.
40 * Reason. Can't be null.
42 public PCEPCloseObject(Reason reason) {
47 * Constructs Close Object also with optional objects.
50 * Reason. Can't be null.
54 public PCEPCloseObject(Reason reason, List<PCEPTlv> tlvs) {
57 throw new IllegalArgumentException("Reason is mandatory.");
63 this.tlvs = Collections.emptyList();
69 * @return Reason. Can't be null.
71 public Reason getReason() {
76 * Gets list of {@link PCEPTlv}
78 * @return List<PCEPTlv>. Can't be null, but may be empty.
80 public List<PCEPTlv> getTlvs() {
85 public int hashCode() {
87 int result = super.hashCode();
88 result = prime * result + ((this.reason == null) ? 0 : this.reason.hashCode());
89 result = prime * result + ((this.tlvs == null) ? 0 : this.tlvs.hashCode());
94 public boolean equals(Object obj) {
97 if (!super.equals(obj))
99 if (this.getClass() != obj.getClass())
101 final PCEPCloseObject other = (PCEPCloseObject) obj;
102 if (this.reason != other.reason)
104 if (this.tlvs == null) {
105 if (other.tlvs != null)
107 } else if (!this.tlvs.equals(other.tlvs))
113 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
114 toStringHelper.add("reason", this.reason);
115 toStringHelper.add("tlvs", this.tlvs);
116 return super.addToStringAttributes(toStringHelper);