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 LSP Object.
21 * href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-8.3">PCEP
24 public class PCEPLspObject extends PCEPObject {
26 private final int lspID;
28 private final boolean delegate;
30 private final boolean sync;
32 private final boolean operational;
34 private final boolean remove;
36 private final List<PCEPTlv> tlvs;
39 * Constructs PCEP LSP Object only with mandatory values.
52 public PCEPLspObject(int lspID, boolean delegate, boolean sync, boolean operational, boolean remove) {
53 this(lspID, delegate, sync, operational, remove, null);
57 * Constructs PCEP LSP Object also with optional Objects.
72 public PCEPLspObject(int lspID, boolean delegate, boolean sync, boolean operational, boolean remove, List<PCEPTlv> tlvs) {
75 this.delegate = delegate;
77 this.operational = operational;
82 this.tlvs = Collections.emptyList();
86 * Gets integer representation of LSP ID.
90 public int getLspID() {
99 public boolean isDelegate() {
100 return this.delegate;
108 public boolean isSync() {
113 * Gets Operational flag.
117 public boolean isOperational() {
118 return this.operational;
126 public boolean isRemove() {
131 * Gets list of {@link PCEPTlv}
133 * @return List<PCEPTlv>. Can't be null, but may be empty.
135 public List<PCEPTlv> getTlvs() {
140 public int hashCode() {
141 final int prime = 31;
142 int result = super.hashCode();
143 result = prime * result + (this.delegate ? 1231 : 1237);
144 result = prime * result + this.lspID;
145 result = prime * result + (this.operational ? 1231 : 1237);
146 result = prime * result + (this.remove ? 1231 : 1237);
147 result = prime * result + (this.sync ? 1231 : 1237);
148 result = prime * result + ((this.tlvs == null) ? 0 : this.tlvs.hashCode());
153 public boolean equals(Object obj) {
156 if (!super.equals(obj))
158 if (this.getClass() != obj.getClass())
160 final PCEPLspObject other = (PCEPLspObject) obj;
161 if (this.delegate != other.delegate)
163 if (this.lspID != other.lspID)
165 if (this.operational != other.operational)
167 if (this.remove != other.remove)
169 if (this.sync != other.sync)
171 if (this.tlvs == null) {
172 if (other.tlvs != null)
174 } else if (!this.tlvs.equals(other.tlvs))
180 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
181 toStringHelper.add("lspID", this.lspID);
182 toStringHelper.add("delegate", this.delegate);
183 toStringHelper.add("sync", this.sync);
184 toStringHelper.add("operational", this.operational);
185 toStringHelper.add("remove", this.remove);
186 toStringHelper.add("tlvs", this.tlvs);
187 return super.addToStringAttributes(toStringHelper);