Skip to content

Commit

Permalink
Added a method to check for static parameters inside of an ActivityType
Browse files Browse the repository at this point in the history
  • Loading branch information
cohansen authored and mattdailis committed Jul 19, 2024
1 parent 4f8a893 commit 1219b52
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ private ActivityTypeRecord parseActivityType(final PackageElement missionModelEl
final var validations = this.getExportValidations(activityTypeElement, parameters);
final var effectModel = this.getActivityEffectModel(activityTypeElement);

if (!parameters.isEmpty()) {
checkForStaticParameters(name, parameters);
}

final var durationParameterName = effectModel.flatMap(EffectModelRecord::durationParameter);
if (durationParameterName.isPresent()) {
validateControllableDurationParameter(name, parameters, durationParameterName.get());
Expand All @@ -409,6 +413,17 @@ class (old-style) or as a record (new-style) by determining
effectModel);
}

private void checkForStaticParameters(String activityName, List<ParameterRecord> parameters) throws InvalidMissionModelException {
for (final var parameter: parameters) {
if (parameter.element.getModifiers().contains(Modifier.STATIC)) {
throw new InvalidMissionModelException(
"In activity " + activityName +
", parameter \"" + parameter.name +"\"" +
" is declared as static, but this is not valid for activity parameters");
}
}
}

private void validateControllableDurationParameter(
final String activityName,
final List<ParameterRecord> parameters,
Expand Down

0 comments on commit 1219b52

Please sign in to comment.