Class ImmutableExecHelper

java.lang.Object
pl.poznan.put.utility.ExecHelper
pl.poznan.put.utility.ImmutableExecHelper

@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ImmutableExecHelper extends ExecHelper
Immutable implementation of ExecHelper.

Use the builder to create immutable instances: ImmutableExecHelper.builder().

  • Method Details

    • workingDirectory

      public Optional<File> workingDirectory()
      Specified by:
      workingDirectory in class ExecHelper
      Returns:
      The working directory where to run the command in.
    • command

      public String command()
      Specified by:
      command in class ExecHelper
      Returns:
      The command to run.
    • environment

      public Map<String,String> environment()
      Overrides:
      environment in class ExecHelper
      Returns:
      The environment variables to be set during external command running (default: empty).
    • arguments

      public List<String> arguments()
      Overrides:
      arguments in class ExecHelper
      Returns:
      The list of arguments to the command (default: empty).
    • withWorkingDirectory

      public final ImmutableExecHelper withWorkingDirectory(File value)
      Copy the current immutable object by setting a present value for the optional workingDirectory attribute.
      Parameters:
      value - The value for workingDirectory
      Returns:
      A modified copy of this object
    • withWorkingDirectory

      public final ImmutableExecHelper withWorkingDirectory(Optional<? extends File> optional)
      Copy the current immutable object by setting an optional value for the workingDirectory attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for workingDirectory
      Returns:
      A modified copy of this object
    • withCommand

      public final ImmutableExecHelper withCommand(String value)
      Copy the current immutable object by setting a value for the command attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for command
      Returns:
      A modified copy of the this object
    • withEnvironment

      public final ImmutableExecHelper withEnvironment(Map<String,? extends String> entries)
      Copy the current immutable object by replacing the environment map with the specified map. Nulls are not permitted as keys or values. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      entries - The entries to be added to the environment map
      Returns:
      A modified copy of this object
    • withArguments

      public final ImmutableExecHelper withArguments(String... elements)
      Copy the current immutable object with elements that replace the content of arguments.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withArguments

      public final ImmutableExecHelper withArguments(Iterable<String> elements)
      Copy the current immutable object with elements that replace the content of arguments. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of arguments elements to set
      Returns:
      A modified copy of this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableExecHelper that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: workingDirectory, command, environment, arguments.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value ExecHelper with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      public static ImmutableExecHelper copyOf(ExecHelper instance)
      Creates an immutable copy of a ExecHelper value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable ExecHelper instance
    • builder

      public static ImmutableExecHelper.Builder builder()
      Creates a builder for ImmutableExecHelper.
       ImmutableExecHelper.builder()
          .workingDirectory(java.io.File) // optional workingDirectory
          .command(String) // required command
          .putEnvironment|putAllEnvironment(String => String) // environment mappings
          .addArguments|addAllArguments(String) // arguments elements
          .build();
       
      Returns:
      A new ImmutableExecHelper builder