blob: 0bcc290784e6e8ec030701ef43ae80b30ea402b8 [file] [log] [blame]
Sho SHIMIZUe81e4db2015-09-03 09:44:38 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17package org.onosproject.pcepio.protocol.ver1;
18
19import org.onosproject.pcepio.exceptions.PcepParseException;
20import org.onosproject.pcepio.protocol.PcepLspObject;
21import org.onosproject.pcepio.protocol.PcepMsgPath;
22import org.onosproject.pcepio.protocol.PcepSrpObject;
23import org.onosproject.pcepio.protocol.PcepUpdateRequest;
24import org.slf4j.Logger;
25import org.slf4j.LoggerFactory;
26
27import com.google.common.base.MoreObjects;
28
29/**
30 * Provides PCEP Update Request List.
31 */
32public class PcepUpdateRequestVer1 implements PcepUpdateRequest {
33
34 /* <update-request-list>
35 * Where:
36 * <update-request-list> ::= <update-request>[<update-request-list>]
37 * <update-request> ::= <SRP>
38 * <LSP>
39 * <path>
40 * Where:
41 * <path> ::= <ERO><attribute-list>
42 * Where:
43 * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
44 */
45
46 protected static final Logger log = LoggerFactory.getLogger(PcepUpdateRequestVer1.class);
47
48 //PCEP SRP Object
49 private PcepSrpObject srpObject;
50 //PCEP LSP Object
51 private PcepLspObject lspObject;
52 //PCEP Message path
53 private PcepMsgPath msgPath;
54
55 /**
56 * Default constructor.
57 */
58 public PcepUpdateRequestVer1() {
59 srpObject = null;
60 lspObject = null;
61 msgPath = null;
62 }
63
64 /**
65 * Constructor to initialize all member variables.
66 *
67 * @param srpObject srp object
68 * @param lspObject lsp object
69 * @param msgPath message path object
70 */
71 public PcepUpdateRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepMsgPath msgPath) {
72 this.srpObject = srpObject;
73 this.lspObject = lspObject;
74 this.msgPath = msgPath;
75 }
76
77 @Override
78 public PcepSrpObject getSrpObject() {
79 return srpObject;
80 }
81
82 @Override
83 public PcepLspObject getLspObject() {
84 return lspObject;
85 }
86
87 @Override
88 public PcepMsgPath getMsgPath() {
89 return msgPath;
90 }
91
92 @Override
93 public void setSrpObject(PcepSrpObject srpObject) {
94 this.srpObject = srpObject;
95
96 }
97
98 @Override
99 public void setLspObject(PcepLspObject lspObject) {
100 this.lspObject = lspObject;
101 }
102
103 @Override
104 public void setMsgPath(PcepMsgPath msgPath) {
105 this.msgPath = msgPath;
106 }
107
108 /**
109 * Builder class for PCEP update request.
110 */
111 public static class Builder implements PcepUpdateRequest.Builder {
112
113 private boolean bIsSRPObjectSet = false;
114 private boolean bIsLSPObjectSet = false;
115 private boolean bIsPcepMsgPathSet = false;
116
117 //PCEP SRP Object
118 private PcepSrpObject srpObject;
119 //PCEP LSP Object
120 private PcepLspObject lspObject;
121 //PCEP Attribute list
122 private PcepMsgPath msgPath;
123
124 @Override
125 public PcepUpdateRequest build() throws PcepParseException {
126
127 //PCEP SRP Object
128 PcepSrpObject srpObject = null;
129 //PCEP LSP Object
130 PcepLspObject lspObject = null;
131 //PCEP Attribute list
132 PcepMsgPath msgPath = null;
133
134 if (!this.bIsSRPObjectSet) {
135 throw new PcepParseException(" SRP Object NOT Set while building PcepUpdateRequest.");
136 } else {
137 srpObject = this.srpObject;
138 }
139 if (!this.bIsLSPObjectSet) {
140 throw new PcepParseException(" LSP Object NOT Set while building PcepUpdateRequest.");
141 } else {
142 lspObject = this.lspObject;
143 }
144 if (!this.bIsPcepMsgPathSet) {
145 throw new PcepParseException(" Msg Path NOT Set while building PcepUpdateRequest.");
146 } else {
147 msgPath = this.msgPath;
148 }
149
150 return new PcepUpdateRequestVer1(srpObject, lspObject, msgPath);
151 }
152
153 @Override
154 public PcepSrpObject getSrpObject() {
155 return this.srpObject;
156 }
157
158 @Override
159 public PcepLspObject getLspObject() {
160 return this.lspObject;
161 }
162
163 @Override
164 public PcepMsgPath getMsgPath() {
165 return this.msgPath;
166 }
167
168 @Override
169 public Builder setSrpObject(PcepSrpObject srpobj) {
170 this.srpObject = srpobj;
171 this.bIsSRPObjectSet = true;
172 return this;
173
174 }
175
176 @Override
177 public Builder setLspObject(PcepLspObject lspObject) {
178 this.lspObject = lspObject;
179 this.bIsLSPObjectSet = true;
180 return this;
181 }
182
183 @Override
184 public Builder setMsgPath(PcepMsgPath msgPath) {
185 this.msgPath = msgPath;
186 this.bIsPcepMsgPathSet = true;
187 return this;
188 }
189 }
190
191 @Override
192 public String toString() {
Sho SHIMIZU7cdbcf72015-09-03 14:43:05 -0700193 return MoreObjects.toStringHelper(getClass())
194 .add("SrpObject", srpObject)
195 .add("LspObject", lspObject)
196 .add("MsgPath", msgPath)
197 .toString();
Sho SHIMIZUe81e4db2015-09-03 09:44:38 -0700198 }
Sho SHIMIZU7cdbcf72015-09-03 14:43:05 -0700199}