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 No Path Object.
20 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.5">PCEP No Path
23 public class PCEPNoPathObject extends PCEPObject {
25 private final short natureOfIssue;
27 private final boolean constrained;
29 private final List<PCEPTlv> tlvs;
32 * Constructs PCEP No Path Object only with mandatory values.
34 * @param natureOfIssue
41 public PCEPNoPathObject(short natureOfIssue, boolean constrained, boolean ignored) {
42 this(natureOfIssue, constrained, null, ignored);
46 * Constructs PCEP No Path Object also with optional Objects.
48 * @param natureOfIssue
57 public PCEPNoPathObject(short natureOfIssue, boolean constrained, List<PCEPTlv> tlvs, boolean ignored) {
58 super(false, ignored);
59 this.natureOfIssue = natureOfIssue;
60 this.constrained = constrained;
64 this.tlvs = Collections.emptyList();
68 * Returns short representation of Nature of issue.
72 public short getNatureOfIssue() {
73 return this.natureOfIssue;
77 * Gets Constrained flag.
81 public boolean isConstrained() {
82 return this.constrained;
86 * Gets list of {@link PCEPTlv}
88 * @return List<PCEPTlv>. Can't be null, but may be empty.
90 public List<PCEPTlv> getTlvs() {
95 public int hashCode() {
97 int result = super.hashCode();
98 result = prime * result + (this.constrained ? 1231 : 1237);
99 result = prime * result + this.natureOfIssue;
100 result = prime * result + ((this.tlvs == null) ? 0 : this.tlvs.hashCode());
105 public boolean equals(Object obj) {
108 if (!super.equals(obj))
110 if (this.getClass() != obj.getClass())
112 final PCEPNoPathObject other = (PCEPNoPathObject) obj;
113 if (this.constrained != other.constrained)
115 if (this.natureOfIssue != other.natureOfIssue)
117 if (this.tlvs == null) {
118 if (other.tlvs != null)
120 } else if (!this.tlvs.equals(other.tlvs))
126 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
127 toStringHelper.add("natureOfIssue", this.natureOfIssue);
128 toStringHelper.add("constrained", this.constrained);
129 toStringHelper.add("tlvs", this.tlvs);
130 return super.addToStringAttributes(toStringHelper);