Skip to main content

Parameters & Invocations

Goals and constraints can be given arguments, much like activities can; they actually use the exact same system. This allows you to configure a goal that needs to be reused in slightly different ways across multiple plans, or even multiple times in the same plan.

Parameters

tip

For now, only Java records are supported for parameterization.

For example, we can take the example from the scheduling page, and parameterize it so that it doesn't unconditionally recur every hour, and instead takes the period as input:

Kotlin parameter mapping is not yet supported :(

After you add the goal to your plan's scheduling specification, you'll see the goal invocation with a period parameter to be filled in.

PlanDev Scheduling - Parameterized Goal
Figure 1: PlanDev Scheduling - Parameterized Goal

Default Parameter Values

Procedural goals and constraints can provide default values for record parameters with a static class annotated with @WithDefaults. Fields present in the defaults class are used as initial values in the UI. Record fields that do not have defaults still need to be provided by the user.

@SchedulingProcedure
public record BiteBananaGoal(int quantity, int biteSize) implements Goal {
@Override
public void run(EditablePlan plan) {
// Goal implementation...
}

public static @WithDefaults class Defaults {
public int quantity = 360;
}
}

In this example, quantity defaults to 360, while biteSize remains required. When defaults are available, the UI shows whether a value came from the procedure default or from a user override, and allows an overridden value to be reset.

Invocations

You can invoke the same goal multiple times in the same specification. This is useful for very specific, targeted goals; so the above goal isn't a very practical example of multiple invocations, but that won't stop us. You can right-click on the invocation and select "Duplicate invocation":

PlanDev Scheduling - Duplicate Invocation
Figure 2: PlanDev Scheduling - Duplicate Invocation

You can then create another invocation of the same goal, but likely with different parameters.