import org.w3c.dom.NodeList;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
/**
* This Class implements a pattern handler tree in the XML-defined state system.
private final XmlPatternStateProvider fParent;
private final List<String> fInitialFsm;
- private final Map<String, TmfXmlTransitionValidator> fTestMap = new HashMap<>();
- private final Map<String, ITmfXmlAction> fActionMap = new HashMap<>();
+ private final Map<String, TmfXmlTransitionValidator> fTestMap;
+ private final Map<String, ITmfXmlAction> fActionMap;
private final Map<String, TmfXmlFsm> fFsmMap = new LinkedHashMap<>();
private final List<TmfXmlFsm> fActiveFsmList = new ArrayList<>();
String initialFsm = node.getAttribute(TmfXmlStrings.INITIAL);
fInitialFsm = initialFsm.isEmpty() ? Collections.EMPTY_LIST : Arrays.asList(initialFsm.split(TmfXmlStrings.AND_SEPARATOR));
+ Map<String, TmfXmlTransitionValidator> testMap = new HashMap<>();
NodeList nodesTest = node.getElementsByTagName(TmfXmlStrings.TEST);
/* load transition input */
for (int i = 0; i < nodesTest.getLength(); i++) {
throw new IllegalArgumentException();
}
TmfXmlTransitionValidator test = modelFactory.createTransitionValidator(element, fParent);
- fTestMap.put(test.getId(), test);
+ testMap.put(test.getId(), test);
}
+ fTestMap = Collections.unmodifiableMap(testMap);
+ @NonNull Builder<String, ITmfXmlAction> builder = ImmutableMap.builder();
NodeList nodesAction = node.getElementsByTagName(TmfXmlStrings.ACTION);
/* load actions */
for (int i = 0; i < nodesAction.getLength(); i++) {
if (element == null) {
throw new IllegalArgumentException();
}
- ITmfXmlAction action = modelFactory.createAction(element, fParent);
- fActionMap.put(((TmfXmlAction) action).getId(), action);
+ TmfXmlAction action = modelFactory.createAction(element, fParent);
+ builder.put(action.getId(), action);
}
- fActionMap.put(TmfXmlStrings.CONSTANT_PREFIX + ITmfXmlAction.CLEAR_STORED_FIELDS_STRING, new ResetStoredFieldsAction(fParent));
- fActionMap.put(TmfXmlStrings.CONSTANT_PREFIX + ITmfXmlAction.SAVE_STORED_FIELDS_STRING, new UpdateStoredFieldsAction(fParent));
+ builder.put(TmfXmlStrings.CONSTANT_PREFIX + ITmfXmlAction.CLEAR_STORED_FIELDS_STRING, new ResetStoredFieldsAction(fParent));
+ builder.put(TmfXmlStrings.CONSTANT_PREFIX + ITmfXmlAction.SAVE_STORED_FIELDS_STRING, new UpdateStoredFieldsAction(fParent));
+ fActionMap = builder.build();
NodeList nodesFsm = node.getElementsByTagName(TmfXmlStrings.FSM);
/* load fsm */
* @return The tests in a map
*/
public Map<String, TmfXmlTransitionValidator> getTestMap() {
- return ImmutableMap.copyOf(fTestMap);
+ return fTestMap;
}
/**
* @return The actions
*/
public Map<String, ITmfXmlAction> getActionMap() {
- return ImmutableMap.copyOf(fActionMap);
+ return fActionMap;
}
/**