Skip to content

Commit

Permalink
Merge pull request #118 from Xiqinger/master
Browse files Browse the repository at this point in the history
add null pointer check to avoid null pointer exception.
  • Loading branch information
pgleeson committed May 17, 2024
2 parents 66acec4 + a9d3c61 commit acebdca
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/lemsml/jlems/core/run/StateInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ public void advance(StateRunnable parent, double t, double dt) throws RuntimeErr


public void transitionTo(String rnm) throws RuntimeError {
if (regimeHM == null) {
throw new IllegalStateException("No Regimes.");
}
activeRegime = regimeHM.get(rnm);
activeRegime.enter();
}
Expand All @@ -314,6 +317,9 @@ public void doneInit() {

public void initRegime() throws RuntimeError {
if (activeRegime == null) {
if (regimeHM == null || regimeHM.isEmpty()) {
throw new IllegalStateException("No Regimes.");
}
activeRegime = regimeHM.get(regimeHM.keySet().iterator().next());
// TODO just picks random regime
}
Expand Down

0 comments on commit acebdca

Please sign in to comment.