Sho SHIMIZU
Committed by Ray Milkey

Replace redundant instanceof with non-null check

Change-Id: Ib86b0c8561824b1753b299f680d7d336205dd9a4
...@@ -283,13 +283,13 @@ public class PcInitiatedLspRequestVer1 implements PcInitiatedLspRequest { ...@@ -283,13 +283,13 @@ public class PcInitiatedLspRequestVer1 implements PcInitiatedLspRequest {
283 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 283 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
284 toStrHelper.add("SrpObject", srpObject).add("LspObject", lspObject); 284 toStrHelper.add("SrpObject", srpObject).add("LspObject", lspObject);
285 285
286 - if (endPointsObject instanceof PcepEndPointsObject) { 286 + if (endPointsObject != null) {
287 toStrHelper.add("EndPointObject", endPointsObject); 287 toStrHelper.add("EndPointObject", endPointsObject);
288 } 288 }
289 - if (eroObject instanceof PcepEroObject) { 289 + if (eroObject != null) {
290 toStrHelper.add("EroObject", eroObject); 290 toStrHelper.add("EroObject", eroObject);
291 } 291 }
292 - if (pcepAttribute instanceof PcepAttribute) { 292 + if (pcepAttribute != null) {
293 toStrHelper.add("PcepAttribute", pcepAttribute); 293 toStrHelper.add("PcepAttribute", pcepAttribute);
294 } 294 }
295 return toStrHelper.toString(); 295 return toStrHelper.toString();
......
...@@ -423,18 +423,18 @@ public class PcepAttributeVer1 implements PcepAttribute { ...@@ -423,18 +423,18 @@ public class PcepAttributeVer1 implements PcepAttribute {
423 public String toString() { 423 public String toString() {
424 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 424 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
425 425
426 - if (lspaObject instanceof PcepLspaObject) { 426 + if (lspaObject != null) {
427 toStrHelper.add("lspaObject", lspaObject); 427 toStrHelper.add("lspaObject", lspaObject);
428 } 428 }
429 - if (bandwidthObject instanceof PcepBandwidthObject) { 429 + if (bandwidthObject != null) {
430 toStrHelper.add("bandwidthObject", bandwidthObject); 430 toStrHelper.add("bandwidthObject", bandwidthObject);
431 } 431 }
432 if (llMetricList instanceof PcepMetricObject) { 432 if (llMetricList instanceof PcepMetricObject) {
433 toStrHelper.add("MetricObjectList", llMetricList); 433 toStrHelper.add("MetricObjectList", llMetricList);
434 } 434 }
435 - if (iroObject instanceof PcepIroObject) { 435 + if (iroObject != null) {
436 toStrHelper.add("IroObject", iroObject); 436 toStrHelper.add("IroObject", iroObject);
437 } 437 }
438 return toStrHelper.toString(); 438 return toStrHelper.toString();
439 } 439 }
440 -}
...\ No newline at end of file ...\ No newline at end of file
440 +}
......
...@@ -146,7 +146,7 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg { ...@@ -146,7 +146,7 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
146 tempObjHeader = parseErrorObjectList(llErrObjList, cb); 146 tempObjHeader = parseErrorObjectList(llErrObjList, cb);
147 147
148 //check whether OPEN-OBJECT is present. 148 //check whether OPEN-OBJECT is present.
149 - if ((tempObjHeader instanceof PcepObjectHeader) 149 + if ((tempObjHeader != null)
150 && (tempObjHeader.getObjClass() == PcepOpenObjectVer1.OPEN_OBJ_CLASS)) { 150 && (tempObjHeader.getObjClass() == PcepOpenObjectVer1.OPEN_OBJ_CLASS)) {
151 151
152 if (llErrObjList.isEmpty()) { 152 if (llErrObjList.isEmpty()) {
...@@ -156,7 +156,7 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg { ...@@ -156,7 +156,7 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
156 PcepOpenObject pcepOpenObj = PcepOpenObjectVer1.read(cb); 156 PcepOpenObject pcepOpenObj = PcepOpenObjectVer1.read(cb);
157 this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList, pcepOpenObj); 157 this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList, pcepOpenObj);
158 158
159 - } else if ((tempObjHeader instanceof PcepObjectHeader) //check whether RP or TE Object is present. 159 + } else if ((tempObjHeader != null) //check whether RP or TE Object is present.
160 && ((tempObjHeader.getObjClass() == PcepRPObjectVer1.RP_OBJ_CLASS) 160 && ((tempObjHeader.getObjClass() == PcepRPObjectVer1.RP_OBJ_CLASS)
161 || (tempObjHeader.getObjClass() == PcepTEObjectVer1.TE_OBJ_CLASS))) { 161 || (tempObjHeader.getObjClass() == PcepTEObjectVer1.TE_OBJ_CLASS))) {
162 162
...@@ -273,10 +273,10 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg { ...@@ -273,10 +273,10 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
273 // write ( <error-obj-list> [<Open>] ) if exists. 273 // write ( <error-obj-list> [<Open>] ) if exists.
274 // otherwise write <error> [<error-list>] 274 // otherwise write <error> [<error-list>]
275 275
276 - if ((errObjListWithOpen instanceof ErrorObjListWithOpen) 276 + if ((errObjListWithOpen != null)
277 && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { 277 && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
278 errObjListWithOpen.write(cb); 278 errObjListWithOpen.write(cb);
279 - } else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) { 279 + } else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
280 errInfo.write(cb); 280 errInfo.write(cb);
281 } else { 281 } else {
282 throw new PcepParseException("Empty PCEP-ERROR message."); 282 throw new PcepParseException("Empty PCEP-ERROR message.");
...@@ -324,10 +324,10 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg { ...@@ -324,10 +324,10 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
324 */ 324 */
325 public LinkedList<Integer> getErrorType() { 325 public LinkedList<Integer> getErrorType() {
326 LinkedList<Integer> llErrorType = new LinkedList<Integer>(); 326 LinkedList<Integer> llErrorType = new LinkedList<Integer>();
327 - if ((errObjListWithOpen instanceof ErrorObjListWithOpen) 327 + if ((errObjListWithOpen != null)
328 && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { 328 && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
329 llErrorType = errObjListWithOpen.getErrorType(); 329 llErrorType = errObjListWithOpen.getErrorType();
330 - } else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) { 330 + } else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
331 llErrorType = errInfo.getErrorType(); 331 llErrorType = errInfo.getErrorType();
332 } 332 }
333 333
...@@ -341,10 +341,10 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg { ...@@ -341,10 +341,10 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
341 */ 341 */
342 public LinkedList<Integer> getErrorValue() { 342 public LinkedList<Integer> getErrorValue() {
343 LinkedList<Integer> llErrorValue = new LinkedList<Integer>(); 343 LinkedList<Integer> llErrorValue = new LinkedList<Integer>();
344 - if ((errObjListWithOpen instanceof ErrorObjListWithOpen) 344 + if ((errObjListWithOpen != null)
345 && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { 345 && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
346 llErrorValue = errObjListWithOpen.getErrorValue(); 346 llErrorValue = errObjListWithOpen.getErrorValue();
347 - } else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) { 347 + } else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
348 llErrorValue = errInfo.getErrorValue(); 348 llErrorValue = errInfo.getErrorValue();
349 } 349 }
350 350
...@@ -355,11 +355,11 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg { ...@@ -355,11 +355,11 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
355 public String toString() { 355 public String toString() {
356 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 356 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
357 357
358 - if ((errObjListWithOpen instanceof ErrorObjListWithOpen) 358 + if ((errObjListWithOpen != null)
359 && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { 359 && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
360 toStrHelper.add("ErrorObjectListWithOpen", errObjListWithOpen); 360 toStrHelper.add("ErrorObjectListWithOpen", errObjListWithOpen);
361 } 361 }
362 - if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) { 362 + if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
363 toStrHelper.add("ErrorInfo", errInfo); 363 toStrHelper.add("ErrorInfo", errInfo);
364 } 364 }
365 365
......
...@@ -252,7 +252,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg { ...@@ -252,7 +252,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
252 252
253 //Srp Object is mandatory 253 //Srp Object is mandatory
254 PcepSrpObject srpObj = listReq.getSrpObject(); 254 PcepSrpObject srpObj = listReq.getSrpObject();
255 - if (srpObj instanceof PcepSrpObject) { 255 + if (srpObj != null) {
256 isDelLspRequest = srpObj.getRFlag(); 256 isDelLspRequest = srpObj.getRFlag();
257 srpObj.write(cb); 257 srpObj.write(cb);
258 } else { 258 } else {
...@@ -261,7 +261,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg { ...@@ -261,7 +261,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
261 261
262 //LSP Object is mandatory 262 //LSP Object is mandatory
263 PcepLspObject lspObj = listReq.getLspObject(); 263 PcepLspObject lspObj = listReq.getLspObject();
264 - if (lspObj instanceof PcepLspObject) { 264 + if (lspObj != null) {
265 lspObj.write(cb); 265 lspObj.write(cb);
266 } else { 266 } else {
267 throw new PcepParseException("LSP Object is mandatory for PcInitiate message."); 267 throw new PcepParseException("LSP Object is mandatory for PcInitiate message.");
...@@ -275,7 +275,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg { ...@@ -275,7 +275,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
275 275
276 //EndPoints object is mandatory 276 //EndPoints object is mandatory
277 PcepEndPointsObject endPointObj = listReq.getEndPointsObject(); 277 PcepEndPointsObject endPointObj = listReq.getEndPointsObject();
278 - if (endPointObj instanceof PcepEndPointsObject) { 278 + if (endPointObj != null) {
279 endPointObj.write(cb); 279 endPointObj.write(cb);
280 } else { 280 } else {
281 throw new PcepParseException("End points Object is mandatory for PcInitiate message."); 281 throw new PcepParseException("End points Object is mandatory for PcInitiate message.");
...@@ -283,7 +283,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg { ...@@ -283,7 +283,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
283 283
284 //Ero object is mandatory 284 //Ero object is mandatory
285 PcepEroObject eroObj = listReq.getEroObject(); 285 PcepEroObject eroObj = listReq.getEroObject();
286 - if (eroObj instanceof PcepEroObject) { 286 + if (eroObj != null) {
287 eroObj.write(cb); 287 eroObj.write(cb);
288 } else { 288 } else {
289 throw new PcepParseException("ERO Object is mandatory for PcInitiate message."); 289 throw new PcepParseException("ERO Object is mandatory for PcInitiate message.");
...@@ -291,7 +291,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg { ...@@ -291,7 +291,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
291 291
292 //PcepAttribute is optional 292 //PcepAttribute is optional
293 PcepAttribute pcepAttribute = listReq.getPcepAttribute(); 293 PcepAttribute pcepAttribute = listReq.getPcepAttribute();
294 - if (pcepAttribute instanceof PcepAttribute) { 294 + if (pcepAttribute != null) {
295 pcepAttribute.write(cb); 295 pcepAttribute.write(cb);
296 } 296 }
297 } 297 }
......
...@@ -350,10 +350,10 @@ public class PcepLabelUpdateVer1 implements PcepLabelUpdate { ...@@ -350,10 +350,10 @@ public class PcepLabelUpdateVer1 implements PcepLabelUpdate {
350 public String toString() { 350 public String toString() {
351 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 351 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
352 352
353 - if (labelDownload instanceof PcepLabelDownload) { 353 + if (labelDownload != null) {
354 toStrHelper.add("LabelDownload", labelDownload); 354 toStrHelper.add("LabelDownload", labelDownload);
355 } 355 }
356 - if (labelMap instanceof PcepLabelMap) { 356 + if (labelMap != null) {
357 toStrHelper.add("LabelMap", labelMap); 357 toStrHelper.add("LabelMap", labelMap);
358 } 358 }
359 return toStrHelper.toString(); 359 return toStrHelper.toString();
......
...@@ -263,7 +263,7 @@ public class PcepStateReportVer1 implements PcepStateReport { ...@@ -263,7 +263,7 @@ public class PcepStateReportVer1 implements PcepStateReport {
263 public String toString() { 263 public String toString() {
264 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 264 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
265 265
266 - if (attrList instanceof PcepAttribute) { 266 + if (attrList != null) {
267 toStrHelper.add("AttributeList", attrList); 267 toStrHelper.add("AttributeList", attrList);
268 } 268 }
269 if (rroObj instanceof PcepRroObjectVer1) { 269 if (rroObj instanceof PcepRroObjectVer1) {
...@@ -413,15 +413,15 @@ public class PcepStateReportVer1 implements PcepStateReport { ...@@ -413,15 +413,15 @@ public class PcepStateReportVer1 implements PcepStateReport {
413 public String toString() { 413 public String toString() {
414 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 414 ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
415 415
416 - if (this.srpObject instanceof PcepSrpObject) { 416 + if (this.srpObject != null) {
417 toStrHelper.add("SrpObject", srpObject); 417 toStrHelper.add("SrpObject", srpObject);
418 } 418 }
419 - if (this.lspObject instanceof PcepLspObject) { 419 + if (this.lspObject != null) {
420 toStrHelper.add("LspObject", lspObject); 420 toStrHelper.add("LspObject", lspObject);
421 } 421 }
422 - if (this.msgPath instanceof PcepStateReport.PcepMsgPath) { 422 + if (this.msgPath != null) {
423 toStrHelper.add("MsgPath", msgPath); 423 toStrHelper.add("MsgPath", msgPath);
424 } 424 }
425 return toStrHelper.toString(); 425 return toStrHelper.toString();
426 } 426 }
427 -}
...\ No newline at end of file ...\ No newline at end of file
427 +}
......