Class PipelineBuilder


  • public class PipelineBuilder
    extends java.lang.Object
    Fluent builder for constructing Pipeline instances programmatically.

    Example:

     Pipeline pipeline = Pipeline.of("ls -la")
         .pipe("grep pattern")
         .redirect(Path.of("output.txt"))
         .build();
     
    Since:
    4.0
    See Also:
    Pipeline
    • Method Detail

      • pipe

        public PipelineBuilder pipe​(java.lang.String command)
        Adds a pipe (|) to the next command.
        Parameters:
        command - the next command to pipe to
        Returns:
        this builder
      • flip

        public PipelineBuilder flip​(java.lang.String command)
        Adds a flip pipe (|;) to the next command. The output of the previous command is appended as an argument to the next.
        Parameters:
        command - the next command
        Returns:
        this builder
      • and

        public PipelineBuilder and​(java.lang.String command)
        Adds a conditional AND (&&) to the next command. The next command executes only if the previous succeeded.
        Parameters:
        command - the next command
        Returns:
        this builder
      • or

        public PipelineBuilder or​(java.lang.String command)
        Adds a conditional OR (||) to the next command. The next command executes only if the previous failed.
        Parameters:
        command - the next command
        Returns:
        this builder
      • sequence

        public PipelineBuilder sequence​(java.lang.String command)
        Adds a sequence separator (;) to the next command. The next command executes unconditionally after the previous one.
        Parameters:
        command - the next command
        Returns:
        this builder
      • redirect

        public PipelineBuilder redirect​(java.nio.file.Path file)
        Adds an output redirection (>) to the specified file.
        Parameters:
        file - the file to redirect output to
        Returns:
        this builder
      • append

        public PipelineBuilder append​(java.nio.file.Path file)
        Adds an append redirection (>>) to the specified file.
        Parameters:
        file - the file to append output to
        Returns:
        this builder
      • inputRedirect

        public PipelineBuilder inputRedirect​(java.nio.file.Path file)
        Adds an input redirection (<) from the specified file.
        Parameters:
        file - the file to read input from
        Returns:
        this builder
      • stderrRedirect

        public PipelineBuilder stderrRedirect​(java.nio.file.Path file)
        Adds a stderr redirection (2>) to the specified file.
        Parameters:
        file - the file to redirect stderr to
        Returns:
        this builder
      • combinedRedirect

        public PipelineBuilder combinedRedirect​(java.nio.file.Path file)
        Adds a combined stdout+stderr redirection (&>) to the specified file.
        Parameters:
        file - the file to redirect both streams to
        Returns:
        this builder
      • background

        public PipelineBuilder background()
        Marks this pipeline for background execution.
        Returns:
        this builder
      • build

        public Pipeline build()
        Builds the pipeline.
        Returns:
        the constructed pipeline