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.List;
12 import org.opendaylight.protocol.pcep.PCEPObject;
13 import com.google.common.base.Objects.ToStringHelper;
16 * Structure of PCEP SVEC Object.
18 * @see <a href="http://tools.ietf.org/html/rfc5440#section-7.13">PCEP SVEC
21 * href="http://tools.ietf.org/html/rfc6006#section-3.12">Synchronization
22 * of P2MP TE Path Computation Requests [RFC6006]</a>
24 public class PCEPSvecObject extends PCEPObject {
26 private final boolean linkDiversed;
28 private final boolean nodeDiversed;
30 private final boolean srlgDiversed;
32 private final boolean paritialPathDiversed;
34 private final boolean linkDirectionDiversed;
36 private final List<Long> requestIDs;
39 * Constructs PCEP SVEC Object.
48 * List<Long>. Can't be null or empty.
52 public PCEPSvecObject(boolean linkDiversed, boolean nodeDiversed, boolean srlgDiversed, boolean partialPathDiversed, boolean linkDirectionDiversed,
53 List<Long> requestIDs, boolean processed) {
54 super(processed, false);
55 this.linkDiversed = linkDiversed;
56 this.nodeDiversed = nodeDiversed;
57 this.srlgDiversed = srlgDiversed;
58 this.paritialPathDiversed = partialPathDiversed;
59 this.linkDirectionDiversed = linkDirectionDiversed;
61 if (requestIDs == null || requestIDs.isEmpty())
62 throw new IllegalArgumentException("RequestIDs can't be null or empty.");
63 this.requestIDs = requestIDs;
67 * Gets Link Diversed flag.
71 public boolean isLinkDiversed() {
72 return this.linkDiversed;
76 * Gets Node Diversed flag.
80 public boolean isNodeDiversed() {
81 return this.nodeDiversed;
85 * Gets Srlg Diversed flag.
89 public boolean isSrlgDiversed() {
90 return this.srlgDiversed;
93 public boolean isParitialPathDiversed() {
94 return this.paritialPathDiversed;
97 public boolean isLinkDirectionDiversed() {
98 return this.linkDirectionDiversed;
102 * Gets list of Long representations of RequestIDs.
104 * @return List<Long>. Can't be null or empty.
106 public List<Long> getRequestIDs() {
107 return this.requestIDs;
111 public int hashCode() {
112 final int prime = 31;
113 int result = super.hashCode();
114 result = prime * result + (this.linkDiversed ? 1231 : 1237);
115 result = prime * result + (this.nodeDiversed ? 1231 : 1237);
116 result = prime * result + ((this.requestIDs == null) ? 0 : this.requestIDs.hashCode());
117 result = prime * result + (this.srlgDiversed ? 1231 : 1237);
122 public boolean equals(Object obj) {
125 if (!super.equals(obj))
127 if (this.getClass() != obj.getClass())
129 final PCEPSvecObject other = (PCEPSvecObject) obj;
130 if (this.linkDiversed != other.linkDiversed)
132 if (this.nodeDiversed != other.nodeDiversed)
134 if (this.requestIDs == null) {
135 if (other.requestIDs != null)
137 } else if (!this.requestIDs.equals(other.requestIDs))
139 if (this.srlgDiversed != other.srlgDiversed)
145 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
146 toStringHelper.add("linkDiversed", this.linkDiversed);
147 toStringHelper.add("nodeDiversed", this.nodeDiversed);
148 toStringHelper.add("srlgDiversed", this.srlgDiversed);
149 toStringHelper.add("paritialPathDiversed", this.paritialPathDiversed);
150 toStringHelper.add("linkDirectionDiversed", this.linkDirectionDiversed);
151 toStringHelper.add("requestIDs", this.requestIDs);
152 return super.addToStringAttributes(toStringHelper);