Package pl.poznan.put.utility
Class ImmutableExecHelper.Builder
java.lang.Object
pl.poznan.put.utility.ImmutableExecHelper.Builder
- Enclosing class:
- ImmutableExecHelper
Builds instances of type
ImmutableExecHelper
.
Initialize attributes and then invoke the build()
method to create an
immutable instance.
Builder
is not thread-safe and generally should not be stored in a field or collection,
but instead used immediately to create instances.
-
Method Summary
Modifier and TypeMethodDescriptionaddAllArguments
(Iterable<String> elements) Adds elements toarguments
list.addArguments
(String element) Adds one element toarguments
list.addArguments
(String... elements) Adds elements toarguments
list.Sets or replaces all elements forarguments
list.build()
Builds a newImmutableExecHelper
.Initializes the value for thecommand
attribute.environment
(Map<String, ? extends String> entries) Sets or replaces all mappings from the specified map as entries for theenvironment
map.from
(ExecHelper instance) Fill a builder with attribute values from the providedExecHelper
instance.putAllEnvironment
(Map<String, ? extends String> entries) Put all mappings from the specified map as entries toenvironment
map.putEnvironment
(String key, String value) Put one entry to theenvironment
map.putEnvironment
(Map.Entry<String, ? extends String> entry) Put one entry to theenvironment
map.workingDirectory
(File workingDirectory) Initializes the optional valueworkingDirectory
to workingDirectory.workingDirectory
(Optional<? extends File> workingDirectory) Initializes the optional valueworkingDirectory
to workingDirectory.
-
Method Details
-
from
Fill a builder with attribute values from the providedExecHelper
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
workingDirectory
Initializes the optional valueworkingDirectory
to workingDirectory.- Parameters:
workingDirectory
- The value for workingDirectory- Returns:
this
builder for chained invocation
-
workingDirectory
public final ImmutableExecHelper.Builder workingDirectory(Optional<? extends File> workingDirectory) Initializes the optional valueworkingDirectory
to workingDirectory.- Parameters:
workingDirectory
- The value for workingDirectory- Returns:
this
builder for use in a chained invocation
-
command
Initializes the value for thecommand
attribute.- Parameters:
command
- The value for command- Returns:
this
builder for use in a chained invocation
-
putEnvironment
Put one entry to theenvironment
map.- Parameters:
key
- The key in the environment mapvalue
- The associated value in the environment map- Returns:
this
builder for use in a chained invocation
-
putEnvironment
Put one entry to theenvironment
map. Nulls are not permitted- Parameters:
entry
- The key and value entry- Returns:
this
builder for use in a chained invocation
-
environment
Sets or replaces all mappings from the specified map as entries for theenvironment
map. Nulls are not permitted- Parameters:
entries
- The entries that will be added to the environment map- Returns:
this
builder for use in a chained invocation
-
putAllEnvironment
Put all mappings from the specified map as entries toenvironment
map. Nulls are not permitted- Parameters:
entries
- The entries that will be added to the environment map- Returns:
this
builder for use in a chained invocation
-
addArguments
Adds one element toarguments
list.- Parameters:
element
- A arguments element- Returns:
this
builder for use in a chained invocation
-
addArguments
Adds elements toarguments
list.- Parameters:
elements
- An array of arguments elements- Returns:
this
builder for use in a chained invocation
-
arguments
Sets or replaces all elements forarguments
list.- Parameters:
elements
- An iterable of arguments elements- Returns:
this
builder for use in a chained invocation
-
addAllArguments
Adds elements toarguments
list.- Parameters:
elements
- An iterable of arguments elements- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableExecHelper
.- Returns:
- An immutable instance of ExecHelper
- Throws:
IllegalStateException
- if any required attributes are missing
-