tmf: Modernize ITmfEventField
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / event / ITmfEventField.java
index f8fcb6a65f9d35deff7fcc08ce10abf6bb513677..72f250f6d1110e0cee8a56888004eef6bca18faf 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
+ * Copyright (c) 2012, 2014 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -8,10 +8,15 @@
  *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Alexandre Montplaisir - Removed arrays from the API
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.event;
 
+import java.util.Collection;
+
+import org.eclipse.jdt.annotation.NonNull;
+
 /**
  * The generic event payload in TMF. Each field can be either a terminal or
  * further decomposed into subfields.
@@ -31,7 +36,7 @@ public interface ITmfEventField {
     /**
      * The root field id (the main container)
      */
-    public static final String ROOT_FIELD_ID = ":root:"; //$NON-NLS-1$
+    public static final @NonNull String ROOT_FIELD_ID = ":root:"; //$NON-NLS-1$
 
     // ------------------------------------------------------------------------
     // Getters
@@ -54,20 +59,22 @@ public interface ITmfEventField {
     String getFormattedValue();
 
     /**
-     * @return the list of subfield names (empty array if none)
-     */
-    String[] getFieldNames();
-
-    /**
-     * @param index The index of the field
-     * @return the nth field name (null if absent or inexistent)
+     * Return the subfield names. The iteration order is the same as
+     * {@link #getFields()}. The returned Collection is immutable.
+     *
+     * @return The subfield names (empty Collection if none)
+     * @since 3.0
      */
-    String getFieldName(int index);
+    Collection<String> getFieldNames();
 
     /**
-     * @return the list of subfields (empty array if none)
+     * Return the subfield. The iteration order is the same as
+     * {@link #getFieldNames()}. The returned Collection is immutable.
+     *
+     * @return The subfields (empty Collection if none)
+     * @since 3.0
      */
-    ITmfEventField[] getFields();
+    Collection<? extends ITmfEventField> getFields();
 
     /**
      * @param name The name of the field
@@ -75,12 +82,6 @@ public interface ITmfEventField {
      */
     ITmfEventField getField(String name);
 
-    /**
-     * @param index The index of the field to return
-     * @return a specific subfield by index (null if absent or inexistent)
-     */
-    ITmfEventField getField(int index);
-
     /**
      * Gets the a sub-field of this field, which may be multiple levels down.
      *
@@ -90,6 +91,6 @@ public interface ITmfEventField {
      *         found
      * @since 3.0
      */
-    ITmfEventField getSubField(String[] path);
+    ITmfEventField getSubField(String... path);
 
 }
This page took 0.026469 seconds and 5 git commands to generate.