timing.core: Simplify CalledFunctionFactory
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Sat, 1 Oct 2016 12:31:27 +0000 (08:31 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 2 Nov 2016 15:20:59 +0000 (11:20 -0400)
Remove duplicated lines.
Make factory implementation final.

Change-Id: Iee670eb29e514107ec6d0a18fc8e1ed83edccca5
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/82315
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/callgraph/CalledFunctionFactory.java

index 6f91b59a4bcadc4b785011cce80e930d8bbe4710..6a3e9ce2b4f64083dff5930d7735a998c528237f 100644 (file)
@@ -17,7 +17,7 @@ import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
  *
  * @author Matthew Khouzam
  */
-public class CalledFunctionFactory {
+public final class CalledFunctionFactory {
 
     private static final String SEPARATOR = ": "; //$NON-NLS-1$
     private static final String ERROR_MSG = "Cannot create a called function of type : "; //$NON-NLS-1$
@@ -45,18 +45,18 @@ public class CalledFunctionFactory {
      */
     public static AbstractCalledFunction create(long start, long end, int depth, ITmfStateValue stateValue, int processId, @Nullable ICalledFunction parent) {
         switch (stateValue.getType()) {
-        case CUSTOM:
-            throw new IllegalArgumentException(ERROR_MSG + stateValue.getType() + SEPARATOR + stateValue.toString());
-        case DOUBLE:
-            throw new IllegalArgumentException(ERROR_MSG + stateValue.getType() + SEPARATOR + stateValue.toString());
         case INTEGER:
             return create(start, end, depth, stateValue.unboxInt(), processId, parent);
         case LONG:
             return create(start, end, depth, stateValue.unboxLong(), processId, parent);
-        case NULL:
-            throw new IllegalArgumentException(ERROR_MSG + stateValue.getType() + SEPARATOR + stateValue.toString());
         case STRING:
             return create(start, end, depth, stateValue.unboxStr(), processId, parent);
+        case CUSTOM:
+            // Fall through
+        case DOUBLE:
+            // Fall through
+        case NULL:
+            // Fall through
         default:
             throw new IllegalArgumentException(ERROR_MSG + stateValue.getType() + SEPARATOR + stateValue.toString());
         }
@@ -105,7 +105,7 @@ public class CalledFunctionFactory {
      *            the parent node
      * @return an ICalledFunction with the specified properties
      */
-    public static CalledStringFunction create(long start, long end, int depth, String value, int processId,  @Nullable ICalledFunction parent) {
+    public static CalledStringFunction create(long start, long end, int depth, String value, int processId, @Nullable ICalledFunction parent) {
         if (start > end) {
             throw new IllegalArgumentException(Messages.TimeError + '[' + start + ',' + end + ']');
         }
This page took 0.027954 seconds and 5 git commands to generate.