releng: Transition to jdt.annotation 2.0
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.core / src / org / eclipse / tracecompass / tmf / analysis / xml / core / model / TmfXmlCondition.java
index 51a0d6774fff9ef397de49cb7e8a3414843f4595..ebb4e6598e20a8558adfc7a66611c5e4b3b32e2a 100644 (file)
@@ -85,7 +85,7 @@ public class TmfXmlCondition {
 
         Element rootNode = node;
         /* Process the conditions: in each case, only process Element nodes */
-        List<Element> childElements = XmlUtils.getChildElements(rootNode);
+        List<@Nullable Element> childElements = XmlUtils.getChildElements(rootNode);
 
         /*
          * If the node is an if, take the child as the root condition
@@ -100,6 +100,10 @@ public class TmfXmlCondition {
             childElements = XmlUtils.getChildElements(rootNode);
         }
 
+        if (rootNode == null) {
+            throw new IllegalArgumentException();
+        }
+
         switch (rootNode.getNodeName()) {
         case TmfXmlStrings.CONDITION:
             fOperator = LogicalOperator.NONE;
@@ -141,8 +145,13 @@ public class TmfXmlCondition {
              * A state value is either preceded by an eventField or a number of
              * state attributes
              */
-            if (childElements.size() == 1 && childElements.get(0).getNodeName().equals(TmfXmlStrings.ELEMENT_FIELD)) {
-                String attribute = childElements.get(0).getAttribute(TmfXmlStrings.NAME);
+            @Nullable Element firstChild = childElements.get(0);
+            if (firstChild == null) {
+                throw new IllegalStateException();
+            }
+
+            if (childElements.size() == 1 && firstChild.getNodeName().equals(TmfXmlStrings.ELEMENT_FIELD)) {
+                String attribute = firstChild.getAttribute(TmfXmlStrings.NAME);
                 if (attribute == null) {
                     throw new IllegalArgumentException();
                 }
@@ -150,7 +159,7 @@ public class TmfXmlCondition {
             } else {
                 List<ITmfXmlStateAttribute> attributes = new ArrayList<>();
                 for (Element element : childElements) {
-                    if (!element.getNodeName().equals(TmfXmlStrings.STATE_ATTRIBUTE)) {
+                    if (element == null || !element.getNodeName().equals(TmfXmlStrings.STATE_ATTRIBUTE)) {
                         throw new IllegalArgumentException("TmfXmlCondition: a condition either has a eventField element or a number of TmfXmlStateAttribute elements before the state value"); //$NON-NLS-1$
                     }
                     ITmfXmlStateAttribute attribute = modelFactory.createStateAttribute(element, fContainer);
This page took 0.026249 seconds and 5 git commands to generate.