Replace redundant instanceof with non-null check

Change-Id: Ib86b0c8561824b1753b299f680d7d336205dd9a4
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java
index 2326804..fbbba27 100644
--- a/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java
@@ -146,7 +146,7 @@
             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 @@
                 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 @@
             // 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 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 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 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);
         }