Skip to content

Commit

Permalink
feat: add source in select plan event
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-elena committed Jun 4, 2024
1 parent d078d1b commit fdbe9a2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/java/event/planEvent/SelectPlanEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
import event.Event;
import event.eventInfo.PlanInfo;
import jason.asSemantics.Option;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;

import java.util.List;
import java.util.Optional;

/**
* A class that representing an event for a plan selection.
*/
public class SelectPlanEvent implements Event {

private final String event;
private final Optional<List<String>> sources;
private final List<PlanInfo> planOptions;
private PlanInfo selectedPlan;

Expand All @@ -22,7 +25,8 @@ public class SelectPlanEvent implements Event {
* @param options a list of options to select from
*/
public SelectPlanEvent(Trigger trigger, List<Option> options) {
this.event = trigger.getLiteral().toString();
this.event = trigger.getLiteral().getFunctor();
this.sources = trigger.getLiteral().getSources() == null ? Optional.empty() : Optional.of(trigger.getLiteral().getSources().getAsList().stream().map(Term::toString).toList());
this.planOptions = options.stream().map(p -> new PlanInfo(p.getPlan())).toList();
}

Expand Down

0 comments on commit fdbe9a2

Please sign in to comment.