Search in sources :

Example 1 with InputType

use of io.engineblock.activityapi.input.InputType in project engineblock by engineblock.

the class CoreServices method getInputDispenser.

// public static <A extends Activity> Optional<IntPredicateDispenser> getResultFilterDispenser(A activity) {
// Optional<IntPredicateDispenser> intPredicateDispenser = new SimpleConfig(activity, "resultfilter")
// .getString("type")
// .flatMap(ExperimentalResultFilterType.FINDER::get)
// .map(rft -> rft.getFilterDispenser(activity));
// return intPredicateDispenser;
// }
// 
public static <A extends Activity> InputDispenser getInputDispenser(A activity) {
    String inputTypeName = new SimpleConfig(activity, "input").getString("type").orElse("targetrate");
    InputType inputType = InputType.FINDER.getOrThrow(inputTypeName);
    InputDispenser dispenser = inputType.getInputDispenser(activity);
    Optional<Predicate<ResultReadable>> inputFilterDispenser = getInputFilter(activity);
    if (inputFilterDispenser.isPresent()) {
        dispenser = new FilteringInputDispenser(dispenser, inputFilterDispenser.get());
    }
    return dispenser;
}
Also used : SimpleConfig(io.engineblock.util.SimpleConfig) InputType(io.engineblock.activityapi.input.InputType) InputDispenser(io.engineblock.activityapi.input.InputDispenser) Predicate(java.util.function.Predicate)

Example 2 with InputType

use of io.engineblock.activityapi.input.InputType in project engineblock by engineblock.

the class CoreInputDispenser method createInput.

private synchronized Input createInput(long slot) {
    SimpleConfig conf = new SimpleConfig(activity, "input");
    String inputType = conf.getString("type").orElse("targetrate");
    InputType inputTypeImpl = InputType.FINDER.getOrThrow(inputType);
    InputDispenser inputDispenser = inputTypeImpl.getInputDispenser(activity);
    if (inputDispenser instanceof ActivitiesAware) {
        ((ActivitiesAware) inputDispenser).setActivitiesMap(activities);
    }
    Input input = inputDispenser.getInput(slot);
    return input;
}
Also used : SimpleConfig(io.engineblock.util.SimpleConfig) Input(io.engineblock.activityapi.input.Input) InputType(io.engineblock.activityapi.input.InputType) InputDispenser(io.engineblock.activityapi.input.InputDispenser) ActivitiesAware(io.engineblock.activityapi.core.ActivitiesAware)

Aggregations

InputDispenser (io.engineblock.activityapi.input.InputDispenser)2 InputType (io.engineblock.activityapi.input.InputType)2 SimpleConfig (io.engineblock.util.SimpleConfig)2 ActivitiesAware (io.engineblock.activityapi.core.ActivitiesAware)1 Input (io.engineblock.activityapi.input.Input)1 Predicate (java.util.function.Predicate)1