tmf: Introduce resolveIntEventAspectOfClassForEvent
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / trace / TmfTraceUtils.java
index aa2c038994504809414b5f5f4c32ee548d1c95a6..3cfee8a6771e688c6bff976f2f85d3815ae59827 100644 (file)
@@ -113,6 +113,31 @@ public final class TmfTraceUtils {
         return null;
     }
 
+    /**
+     * Return the first result of the first aspect that resolves as non null for
+     * the event received in parameter. The result is cast to an Integer if
+     * possible, otherwise null is returned.
+     *
+     * @param trace
+     *            The trace for which you want the event aspects
+     * @param aspectClass
+     *            The class of the aspect(s) to resolve
+     * @param event
+     *            The event for which to get the aspect
+     * @return Integer of the first result of the
+     *         {@link ITmfEventAspect#resolve(ITmfEvent)} that returns non null
+     *         for the event or {@code null} otherwise
+     * @since 2.0
+     */
+    public static @Nullable <T extends ITmfEventAspect> Integer resolveIntEventAspectOfClassForEvent(
+            ITmfTrace trace, Class<T> aspectClass, ITmfEvent event) {
+        Object result = resolveEventAspectOfClassForEvent(trace, aspectClass, event);
+        if (result instanceof Integer) {
+            return (Integer) result;
+        }
+        return null;
+    }
+
     /**
      * Checks for text file.
      *
This page took 0.046272 seconds and 5 git commands to generate.