diff --git a/AlgebraicDataflowArchitectureModel/src/simulator/Resource.java b/AlgebraicDataflowArchitectureModel/src/simulator/Resource.java index 5f7e67d..665d4a9 100644 --- a/AlgebraicDataflowArchitectureModel/src/simulator/Resource.java +++ b/AlgebraicDataflowArchitectureModel/src/simulator/Resource.java @@ -89,6 +89,10 @@ public ResourceState getState() { return state; } + + public void changeState(ResourceState state) { + this.state = state; + } public Constant getParameter() { return parameter; @@ -99,22 +103,26 @@ if (resourceHierarchy.getChildren().size() > 0) { children = new ArrayList<>(); ResourceHierarchy childRes = resourceHierarchy.getChildren().iterator().next(); - Map childStates = ((CompositeResourceState) state).getChildStates(); if (childRes.getNumParameters() > 0) { // List or Map type. - for (Map.Entry childEnt: childStates.entrySet()) { - String childParam = childEnt.getKey(); - ResourceState childState = childEnt.getValue(); - Type thisType = resourceHierarchy.getResourceStateType(); - if (DataConstraintModel.typeList.isAncestorOf(thisType)) { - children.add(new Resource(childRes, this, new Constant(childParam, DataConstraintModel.typeInt), childState)); - } else if (DataConstraintModel.typeMap.isAncestorOf(thisType)) { - children.add(new Resource(childRes, this, new Constant(childParam, DataConstraintModel.typeString), childState)); + if (state instanceof CompositeResourceState) { + // If the list or map is not nil. + Map childStates = ((CompositeResourceState) state).getChildStates(); + for (Map.Entry childEnt: childStates.entrySet()) { + String childParam = childEnt.getKey(); + ResourceState childState = childEnt.getValue(); + Type thisType = resourceHierarchy.getResourceStateType(); + if (DataConstraintModel.typeList.isAncestorOf(thisType)) { + children.add(new Resource(childRes, this, new Constant(childParam, DataConstraintModel.typeInt), childState)); + } else if (DataConstraintModel.typeMap.isAncestorOf(thisType)) { + children.add(new Resource(childRes, this, new Constant(childParam, DataConstraintModel.typeString), childState)); + } } } } else { // Json type. if (this.children == null) { + Map childStates = ((CompositeResourceState) state).getChildStates(); for (Map.Entry childEnt: childStates.entrySet()) { String childParam = childEnt.getKey(); ResourceState childState = childEnt.getValue();