use of com.facebook.buck.util.Optionals in project buck by facebook.
the class AbstractGenruleDescription method createBuildRule.
@Override
public <A extends T> BuildRule createBuildRule(final TargetGraph targetGraph, final BuildRuleParams params, final BuildRuleResolver resolver, final A args) throws NoSuchBuildTargetException {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
java.util.function.Function<String, com.facebook.buck.rules.args.Arg> macroArgFunction = MacroArg.toMacroArgFunction(getMacroHandler(params.getBuildTarget(), params.getProjectFilesystem(), resolver, targetGraph, args), params.getBuildTarget(), params.getCellRoots(), resolver)::apply;
final Optional<com.facebook.buck.rules.args.Arg> cmd = args.cmd.map(macroArgFunction);
final Optional<com.facebook.buck.rules.args.Arg> bash = args.bash.map(macroArgFunction);
final Optional<com.facebook.buck.rules.args.Arg> cmdExe = args.cmdExe.map(macroArgFunction);
return createBuildRule(params.copyReplacingExtraDeps(Suppliers.ofInstance(Stream.concat(ruleFinder.filterBuildRuleInputs(args.srcs).stream(), Stream.of(cmd, bash, cmdExe).flatMap(Optionals::toStream).flatMap(input -> input.getDeps(ruleFinder).stream())).collect(MoreCollectors.toImmutableSortedSet(Comparator.<BuildRule>naturalOrder())))), resolver, args, cmd, bash, cmdExe);
}
Aggregations