-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More plan class refinements and adaptation of those changes to the le…
…sson classes
- Loading branch information
1 parent
c6acdc8
commit 6c23f16
Showing
17 changed files
with
286 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
simulation/src/main/java/gov/hhs/aspr/ms/gcm/simulation/nucleus/ConsumerDataManagerPlan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package gov.hhs.aspr.ms.gcm.simulation.nucleus; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import gov.hhs.aspr.ms.util.errors.ContractException; | ||
|
||
public class ConsumerDataManagerPlan extends DataManagerPlan { | ||
|
||
private final Consumer<DataManagerContext> consumer; | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time active status arrivalId and | ||
* consumer | ||
* | ||
* @throw {@link ContractException} | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if the consumer is | ||
* null</li> | ||
* </ul> | ||
* | ||
*/ | ||
public ConsumerDataManagerPlan(double time, boolean active, long arrivalId, Consumer<DataManagerContext> consumer) { | ||
super(time, active, arrivalId); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
|
||
this.consumer = consumer; | ||
} | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time, active status and consumer. | ||
* The arrival id is set to -1L indicating that this is a new, non-deserialized | ||
* plan. | ||
* | ||
* @throw {@link ContractException} | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if the consumer is | ||
* null</li> | ||
* </ul> | ||
* | ||
*/ | ||
public ConsumerDataManagerPlan(double time, boolean active, Consumer<DataManagerContext> consumer) { | ||
super(time, active); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
this.consumer = consumer; | ||
} | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time and consumer. The plan will | ||
* be active.The arrival id is set to -1L indicating that this is a new, | ||
* non-deserialized plan. | ||
* | ||
* @throw {@link ContractException} | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if the consumer is | ||
* null</li> | ||
* </ul> | ||
* | ||
*/ | ||
public ConsumerDataManagerPlan(double time, Consumer<DataManagerContext> consumer) { | ||
super(time); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
|
||
this.consumer = consumer; | ||
} | ||
|
||
@Override | ||
protected void execute(DataManagerContext context) { | ||
this.consumer.accept(context); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
simulation/src/main/java/gov/hhs/aspr/ms/gcm/simulation/nucleus/ConsumerReportPlan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package gov.hhs.aspr.ms.gcm.simulation.nucleus; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import gov.hhs.aspr.ms.util.errors.ContractException; | ||
|
||
public class ConsumerReportPlan extends ReportPlan { | ||
|
||
private final Consumer<ReportContext> consumer; | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time, arrivalId and consumer. | ||
* Report plans are always passive. | ||
* | ||
* @throw {@link ContractException} | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if the consumer is | ||
* null</li> | ||
* </ul> | ||
* | ||
*/ | ||
public ConsumerReportPlan(double time, long arrivalId, Consumer<ReportContext> consumer) { | ||
super(time, arrivalId); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
this.consumer = consumer; | ||
} | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time and consumer. Report plans | ||
* are always passive.The arrival id is set to -1L indicating that this is a | ||
* new, non-deserialized plan. | ||
* | ||
* @throw {@link ContractException} | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if the consumer is | ||
* null</li> | ||
* </ul> | ||
* | ||
*/ | ||
public ConsumerReportPlan(double time, Consumer<ReportContext> consumer) { | ||
super(time); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
this.consumer = consumer; | ||
} | ||
|
||
@Override | ||
protected void execute(ReportContext context) { | ||
this.consumer.accept(context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 20 additions & 48 deletions
68
simulation/src/main/java/gov/hhs/aspr/ms/gcm/simulation/nucleus/DataManagerPlan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,49 @@ | ||
package gov.hhs.aspr.ms.gcm.simulation.nucleus; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import gov.hhs.aspr.ms.util.errors.ContractException; | ||
|
||
public class DataManagerPlan extends Plan { | ||
public abstract class DataManagerPlan extends Plan { | ||
// The data manager id is used by the simulation via package access | ||
DataManagerId dataManagerId; | ||
|
||
private final Consumer<DataManagerContext> consumer; | ||
|
||
|
||
/** | ||
* Constructs the plan scheduled for the given time active status arrivalId and | ||
* consumer | ||
* | ||
* @throw {@link ContractException} | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if the consumer is | ||
* null</li> | ||
* </ul> | ||
* Constructs the plan scheduled for the given time active status and arrivalId. | ||
* | ||
*/ | ||
public DataManagerPlan(double time, boolean active, long arrivalId, Consumer<DataManagerContext> consumer) { | ||
public DataManagerPlan(double time, boolean active, long arrivalId) { | ||
super(time, active, arrivalId, Planner.DATA_MANAGER); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
|
||
this.consumer = consumer; | ||
|
||
} | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time, active status and consumer. | ||
* Constructs the plan scheduled for the given time and active status. | ||
* The arrival id is set to -1L indicating that this is a new, non-deserialized | ||
* plan. | ||
* | ||
* @throw {@link ContractException} | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if the consumer is | ||
* null</li> | ||
* </ul> | ||
* | ||
*/ | ||
public DataManagerPlan(double time, boolean active, Consumer<DataManagerContext> consumer) { | ||
public DataManagerPlan(double time, boolean active) { | ||
super(time, active, -1L, Planner.DATA_MANAGER); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
this.consumer = consumer; | ||
|
||
} | ||
|
||
/** | ||
* Constructs the plan scheduled for the given time and consumer. The plan will | ||
* Constructs the plan scheduled for the given time. The plan will | ||
* be active.The arrival id is set to -1L indicating that this is a new, | ||
* non-deserialized plan. | ||
* | ||
* @throw {@link ContractException} | ||
* <ul> | ||
* <li>{@linkplain NucleusError#NULL_PLAN_CONSUMER} if the consumer is | ||
* null</li> | ||
* </ul> | ||
* | ||
*/ | ||
public DataManagerPlan(double time, Consumer<DataManagerContext> consumer) { | ||
public DataManagerPlan(double time) { | ||
super(time, true, -1L, Planner.DATA_MANAGER); | ||
if (consumer == null) { | ||
throw new ContractException(NucleusError.NULL_PLAN_CONSUMER); | ||
} | ||
|
||
this.consumer = consumer; | ||
} | ||
|
||
protected void execute(DataManagerContext context) { | ||
this.consumer.accept(context); | ||
|
||
} | ||
|
||
/** | ||
* Executes the data manager logic associated with the plan. | ||
*/ | ||
protected abstract void execute(DataManagerContext context); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.