Skip to content

Commit

Permalink
Merge pull request #120 from LEMS/experimental
Browse files Browse the repository at this point in the history
add null pointer check to avoid null pointer exception.
  • Loading branch information
pgleeson authored Jun 11, 2024
2 parents 4179fb1 + e7f535c commit 0e3376f
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 0e3376f

Please sign in to comment.