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 {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("SrpObject", srpObject).add("LspObject", lspObject);
if (endPointsObject instanceof PcepEndPointsObject) {
if (endPointsObject != null) {
toStrHelper.add("EndPointObject", endPointsObject);
}
if (eroObject instanceof PcepEroObject) {
if (eroObject != null) {
toStrHelper.add("EroObject", eroObject);
}
if (pcepAttribute instanceof PcepAttribute) {
if (pcepAttribute != null) {
toStrHelper.add("PcepAttribute", pcepAttribute);
}
return toStrHelper.toString();
......
......@@ -423,18 +423,18 @@ public class PcepAttributeVer1 implements PcepAttribute {
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
if (lspaObject instanceof PcepLspaObject) {
if (lspaObject != null) {
toStrHelper.add("lspaObject", lspaObject);
}
if (bandwidthObject instanceof PcepBandwidthObject) {
if (bandwidthObject != null) {
toStrHelper.add("bandwidthObject", bandwidthObject);
}
if (llMetricList instanceof PcepMetricObject) {
toStrHelper.add("MetricObjectList", llMetricList);
}
if (iroObject instanceof PcepIroObject) {
if (iroObject != null) {
toStrHelper.add("IroObject", iroObject);
}
return toStrHelper.toString();
}
}
\ No newline at end of file
}
......
......@@ -146,7 +146,7 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
tempObjHeader = parseErrorObjectList(llErrObjList, cb);
//check whether OPEN-OBJECT is present.
if ((tempObjHeader instanceof PcepObjectHeader)
if ((tempObjHeader != null)
&& (tempObjHeader.getObjClass() == PcepOpenObjectVer1.OPEN_OBJ_CLASS)) {
if (llErrObjList.isEmpty()) {
......@@ -156,7 +156,7 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
PcepOpenObject pcepOpenObj = PcepOpenObjectVer1.read(cb);
this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList, pcepOpenObj);
} else if ((tempObjHeader instanceof PcepObjectHeader) //check whether RP or TE Object is present.
} else if ((tempObjHeader != null) //check whether RP or TE Object is present.
&& ((tempObjHeader.getObjClass() == PcepRPObjectVer1.RP_OBJ_CLASS)
|| (tempObjHeader.getObjClass() == PcepTEObjectVer1.TE_OBJ_CLASS))) {
......@@ -273,10 +273,10 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
// write ( <error-obj-list> [<Open>] ) if exists.
// otherwise write <error> [<error-list>]
if ((errObjListWithOpen instanceof ErrorObjListWithOpen)
if ((errObjListWithOpen != null)
&& (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
errObjListWithOpen.write(cb);
} else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) {
} else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
errInfo.write(cb);
} else {
throw new PcepParseException("Empty PCEP-ERROR message.");
......@@ -324,10 +324,10 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
*/
public LinkedList<Integer> getErrorType() {
LinkedList<Integer> llErrorType = new LinkedList<Integer>();
if ((errObjListWithOpen instanceof ErrorObjListWithOpen)
if ((errObjListWithOpen != null)
&& (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
llErrorType = errObjListWithOpen.getErrorType();
} else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) {
} else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
llErrorType = errInfo.getErrorType();
}
......@@ -341,10 +341,10 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
*/
public LinkedList<Integer> getErrorValue() {
LinkedList<Integer> llErrorValue = new LinkedList<Integer>();
if ((errObjListWithOpen instanceof ErrorObjListWithOpen)
if ((errObjListWithOpen != null)
&& (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
llErrorValue = errObjListWithOpen.getErrorValue();
} else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) {
} else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
llErrorValue = errInfo.getErrorValue();
}
......@@ -355,11 +355,11 @@ public class PcepErrorMsgVer1 implements PcepErrorMsg {
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
if ((errObjListWithOpen instanceof ErrorObjListWithOpen)
if ((errObjListWithOpen != null)
&& (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
toStrHelper.add("ErrorObjectListWithOpen", errObjListWithOpen);
}
if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) {
if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
toStrHelper.add("ErrorInfo", errInfo);
}
......
......@@ -252,7 +252,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
//Srp Object is mandatory
PcepSrpObject srpObj = listReq.getSrpObject();
if (srpObj instanceof PcepSrpObject) {
if (srpObj != null) {
isDelLspRequest = srpObj.getRFlag();
srpObj.write(cb);
} else {
......@@ -261,7 +261,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
//LSP Object is mandatory
PcepLspObject lspObj = listReq.getLspObject();
if (lspObj instanceof PcepLspObject) {
if (lspObj != null) {
lspObj.write(cb);
} else {
throw new PcepParseException("LSP Object is mandatory for PcInitiate message.");
......@@ -275,7 +275,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
//EndPoints object is mandatory
PcepEndPointsObject endPointObj = listReq.getEndPointsObject();
if (endPointObj instanceof PcepEndPointsObject) {
if (endPointObj != null) {
endPointObj.write(cb);
} else {
throw new PcepParseException("End points Object is mandatory for PcInitiate message.");
......@@ -283,7 +283,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
//Ero object is mandatory
PcepEroObject eroObj = listReq.getEroObject();
if (eroObj instanceof PcepEroObject) {
if (eroObj != null) {
eroObj.write(cb);
} else {
throw new PcepParseException("ERO Object is mandatory for PcInitiate message.");
......@@ -291,7 +291,7 @@ class PcepInitiateMsgVer1 implements PcepInitiateMsg {
//PcepAttribute is optional
PcepAttribute pcepAttribute = listReq.getPcepAttribute();
if (pcepAttribute instanceof PcepAttribute) {
if (pcepAttribute != null) {
pcepAttribute.write(cb);
}
}
......
......@@ -350,10 +350,10 @@ public class PcepLabelUpdateVer1 implements PcepLabelUpdate {
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
if (labelDownload instanceof PcepLabelDownload) {
if (labelDownload != null) {
toStrHelper.add("LabelDownload", labelDownload);
}
if (labelMap instanceof PcepLabelMap) {
if (labelMap != null) {
toStrHelper.add("LabelMap", labelMap);
}
return toStrHelper.toString();
......
......@@ -263,7 +263,7 @@ public class PcepStateReportVer1 implements PcepStateReport {
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
if (attrList instanceof PcepAttribute) {
if (attrList != null) {
toStrHelper.add("AttributeList", attrList);
}
if (rroObj instanceof PcepRroObjectVer1) {
......@@ -413,15 +413,15 @@ public class PcepStateReportVer1 implements PcepStateReport {
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
if (this.srpObject instanceof PcepSrpObject) {
if (this.srpObject != null) {
toStrHelper.add("SrpObject", srpObject);
}
if (this.lspObject instanceof PcepLspObject) {
if (this.lspObject != null) {
toStrHelper.add("LspObject", lspObject);
}
if (this.msgPath instanceof PcepStateReport.PcepMsgPath) {
if (this.msgPath != null) {
toStrHelper.add("MsgPath", msgPath);
}
return toStrHelper.toString();
}
}
\ No newline at end of file
}
......