Package pl.poznan.put.utility
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 ofExecHelper.Use the builder to create immutable instances:
ImmutableExecHelper.builder().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableExecHelper.BuilderBuilds instances of typeImmutableExecHelper.-
Nested classes/interfaces inherited from class pl.poznan.put.utility.ExecHelper
ExecHelper.ExecutionResult
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>arguments()static ImmutableExecHelper.Builderbuilder()Creates a builder forImmutableExecHelper.Stringcommand()static ImmutableExecHelpercopyOf(ExecHelper instance)Creates an immutable copy of aExecHelpervalue.Map<String,String>environment()booleanequals(Object another)This instance is equal to all instances ofImmutableExecHelperthat have equal attribute values.inthashCode()Computes a hash code from attributes:workingDirectory,command,environment,arguments.StringtoString()Prints the immutable valueExecHelperwith attribute values.ImmutableExecHelperwithArguments(Iterable<String> elements)Copy the current immutable object with elements that replace the content ofarguments.ImmutableExecHelperwithArguments(String... elements)Copy the current immutable object with elements that replace the content ofarguments.ImmutableExecHelperwithCommand(String value)Copy the current immutable object by setting a value for thecommandattribute.ImmutableExecHelperwithEnvironment(Map<String,? extends String> entries)Copy the current immutable object by replacing theenvironmentmap with the specified map.ImmutableExecHelperwithWorkingDirectory(File value)Copy the current immutable object by setting a present value for the optionalworkingDirectoryattribute.ImmutableExecHelperwithWorkingDirectory(Optional<? extends File> optional)Copy the current immutable object by setting an optional value for theworkingDirectoryattribute.Optional<File>workingDirectory()-
Methods inherited from class pl.poznan.put.utility.ExecHelper
createRandomDirectory, execute
-
-
-
-
Method Detail
-
workingDirectory
public Optional<File> workingDirectory()
- Specified by:
workingDirectoryin classExecHelper- Returns:
- The working directory where to run the command in.
-
command
public String command()
- Specified by:
commandin classExecHelper- Returns:
- The command to run.
-
environment
public Map<String,String> environment()
- Overrides:
environmentin classExecHelper- Returns:
- The environment variables to be set during external command running (default: empty).
-
arguments
public List<String> arguments()
- Overrides:
argumentsin classExecHelper- 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 optionalworkingDirectoryattribute.- Parameters:
value- The value for workingDirectory- Returns:
- A modified copy of
thisobject
-
withWorkingDirectory
public final ImmutableExecHelper withWorkingDirectory(Optional<? extends File> optional)
Copy the current immutable object by setting an optional value for theworkingDirectoryattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for workingDirectory- Returns:
- A modified copy of
thisobject
-
withCommand
public final ImmutableExecHelper withCommand(String value)
Copy the current immutable object by setting a value for thecommandattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for command- Returns:
- A modified copy of the
thisobject
-
withEnvironment
public final ImmutableExecHelper withEnvironment(Map<String,? extends String> entries)
Copy the current immutable object by replacing theenvironmentmap 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 returningthis.- Parameters:
entries- The entries to be added to the environment map- Returns:
- A modified copy of
thisobject
-
withArguments
public final ImmutableExecHelper withArguments(String... elements)
Copy the current immutable object with elements that replace the content ofarguments.- Parameters:
elements- The elements to set- Returns:
- A modified copy of
thisobject
-
withArguments
public final ImmutableExecHelper withArguments(Iterable<String> elements)
Copy the current immutable object with elements that replace the content ofarguments. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
elements- An iterable of arguments elements to set- Returns:
- A modified copy of
thisobject
-
equals
public boolean equals(@Nullable Object another)
This instance is equal to all instances ofImmutableExecHelperthat have equal attribute values.
-
hashCode
public int hashCode()
Computes a hash code from attributes:workingDirectory,command,environment,arguments.
-
toString
public String toString()
Prints the immutable valueExecHelperwith attribute values.
-
copyOf
public static ImmutableExecHelper copyOf(ExecHelper instance)
Creates an immutable copy of aExecHelpervalue. 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 forImmutableExecHelper.ImmutableExecHelper.builder() .workingDirectory(java.io.File) // optionalworkingDirectory.command(String) // requiredcommand.putEnvironment|putAllEnvironment(String => String) //environmentmappings .addArguments|addAllArguments(String) //argumentselements .build();- Returns:
- A new ImmutableExecHelper builder
-
-