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 Notification Object.
20 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.14">PCEP
21 * Notification Object</a>
23 public class PCEPNotificationObject extends PCEPObject {
25 private final short type;
27 private final short value;
29 private List<PCEPTlv> tlvs;
32 * Constructs PCEP Notification Object only with mandatory values.
39 public PCEPNotificationObject(short type, short value) {
40 this(type, value, null);
44 * Constructs PCEP Notification Object also with optional Objects.
53 public PCEPNotificationObject(short type, short value, List<PCEPTlv> tlvs) {
60 this.tlvs = Collections.emptyList();
64 * Returns short representation of Type.
68 public short getType() {
73 * Returns short value.
77 public short getValue() {
82 * Gets list of {@link PCEPTlv}
84 * @return List<PCEPTlv>. Can't be null, but may be empty.
86 public List<PCEPTlv> getTlvs() {
91 public int hashCode() {
93 int result = super.hashCode();
94 result = prime * result + ((this.tlvs == null) ? 0 : this.tlvs.hashCode());
95 result = prime * result + this.type;
96 result = prime * result + this.value;
101 public boolean equals(Object obj) {
104 if (!super.equals(obj))
106 if (this.getClass() != obj.getClass())
108 final PCEPNotificationObject other = (PCEPNotificationObject) obj;
109 if (this.tlvs == null) {
110 if (other.tlvs != null)
112 } else if (!this.tlvs.equals(other.tlvs))
114 if (this.type != other.type)
116 if (this.value != other.value)
122 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
123 toStringHelper.add("type", this.type);
124 toStringHelper.add("value", this.value);
125 toStringHelper.add("tlvs", this.tlvs);
126 return super.addToStringAttributes(toStringHelper);