2 * Copyright 2015 Open Networking Laboratory
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onosproject.pcepio.protocol.ver1;
19 import org.onosproject.pcepio.exceptions.PcepParseException;
20 import org.onosproject.pcepio.protocol.PcepLspObject;
21 import org.onosproject.pcepio.protocol.PcepMsgPath;
22 import org.onosproject.pcepio.protocol.PcepSrpObject;
23 import org.onosproject.pcepio.protocol.PcepUpdateRequest;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 import com.google.common.base.MoreObjects;
30 * Provides PCEP Update Request List.
32 public class PcepUpdateRequestVer1 implements PcepUpdateRequest {
34 /* <update-request-list>
36 * <update-request-list> ::= <update-request>[<update-request-list>]
37 * <update-request> ::= <SRP>
41 * <path> ::= <ERO><attribute-list>
43 * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
46 protected static final Logger log = LoggerFactory.getLogger(PcepUpdateRequestVer1.class);
49 private PcepSrpObject srpObject;
51 private PcepLspObject lspObject;
53 private PcepMsgPath msgPath;
56 * Default constructor.
58 public PcepUpdateRequestVer1() {
65 * Constructor to initialize all member variables.
67 * @param srpObject srp object
68 * @param lspObject lsp object
69 * @param msgPath message path object
71 public PcepUpdateRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepMsgPath msgPath) {
72 this.srpObject = srpObject;
73 this.lspObject = lspObject;
74 this.msgPath = msgPath;
78 public PcepSrpObject getSrpObject() {
83 public PcepLspObject getLspObject() {
88 public PcepMsgPath getMsgPath() {
93 public void setSrpObject(PcepSrpObject srpObject) {
94 this.srpObject = srpObject;
99 public void setLspObject(PcepLspObject lspObject) {
100 this.lspObject = lspObject;
104 public void setMsgPath(PcepMsgPath msgPath) {
105 this.msgPath = msgPath;
109 * Builder class for PCEP update request.
111 public static class Builder implements PcepUpdateRequest.Builder {
113 private boolean bIsSRPObjectSet = false;
114 private boolean bIsLSPObjectSet = false;
115 private boolean bIsPcepMsgPathSet = false;
118 private PcepSrpObject srpObject;
120 private PcepLspObject lspObject;
121 //PCEP Attribute list
122 private PcepMsgPath msgPath;
125 public PcepUpdateRequest build() throws PcepParseException {
128 PcepSrpObject srpObject = null;
130 PcepLspObject lspObject = null;
131 //PCEP Attribute list
132 PcepMsgPath msgPath = null;
134 if (!this.bIsSRPObjectSet) {
135 throw new PcepParseException(" SRP Object NOT Set while building PcepUpdateRequest.");
137 srpObject = this.srpObject;
139 if (!this.bIsLSPObjectSet) {
140 throw new PcepParseException(" LSP Object NOT Set while building PcepUpdateRequest.");
142 lspObject = this.lspObject;
144 if (!this.bIsPcepMsgPathSet) {
145 throw new PcepParseException(" Msg Path NOT Set while building PcepUpdateRequest.");
147 msgPath = this.msgPath;
150 return new PcepUpdateRequestVer1(srpObject, lspObject, msgPath);
154 public PcepSrpObject getSrpObject() {
155 return this.srpObject;
159 public PcepLspObject getLspObject() {
160 return this.lspObject;
164 public PcepMsgPath getMsgPath() {
169 public Builder setSrpObject(PcepSrpObject srpobj) {
170 this.srpObject = srpobj;
171 this.bIsSRPObjectSet = true;
177 public Builder setLspObject(PcepLspObject lspObject) {
178 this.lspObject = lspObject;
179 this.bIsLSPObjectSet = true;
184 public Builder setMsgPath(PcepMsgPath msgPath) {
185 this.msgPath = msgPath;
186 this.bIsPcepMsgPathSet = true;
192 public String toString() {
193 return MoreObjects.toStringHelper(getClass())
194 .add("SrpObject", srpObject)
195 .add("LspObject", lspObject)
196 .add("MsgPath", msgPath)