use of io.engineblock.util.SimpleConfig 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;
}
use of io.engineblock.util.SimpleConfig 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;
}
use of io.engineblock.util.SimpleConfig in project engineblock by engineblock.
the class CoreServices method getOutputDispenser.
public static <A extends Activity> Optional<OutputDispenser> getOutputDispenser(A activity) {
OutputDispenser outputDispenser = new SimpleConfig(activity, "output").getString("type").flatMap(OutputType.FINDER::get).map(mt -> mt.getOutputDispenser(activity)).orElse(null);
if (outputDispenser == null) {
return Optional.empty();
}
Optional<Predicate<ResultReadable>> outputFilterDispenser = getOutputFilter(activity);
if (outputFilterDispenser.isPresent()) {
outputDispenser = new FilteringOutputDispenser(outputDispenser, outputFilterDispenser.get());
}
return Optional.ofNullable(outputDispenser);
}
Aggregations