tmf: Add utility method to retrieve field values
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 5 Jul 2016 19:25:12 +0000 (15:25 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Wed, 6 Jul 2016 19:57:34 +0000 (15:57 -0400)
commit58be3b32784378c7fc3a7b6cad498dfa6071728d
tree63a1de49ed113f1fc87acb2b119a5673a560b283
parenta10a38aec2aeef49c8a73334a13722326daef194
tmf: Add utility method to retrieve field values

It's very common when handling trace events to expect fields
of a certain type. The common pattern to handle an event field
would be:

- field = content.getField()
- make sure field is not null
- value = field.getValue()
- make sure value is not null and of the expected type

Doing this every time we want to read a field is very
cumbersome, we can add a getFieldValue() utility method to
directly get the value into the expected type. So then we
just need to:

- content.getFieldValue(expectedType, fieldName);
- null-check the result

Change-Id: Icff8de7772d8ba8ed66880668cf14c26a07b2573
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/76646
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventFieldTest.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java
This page took 0.024981 seconds and 5 git commands to generate.