Skip to content

Package io.github.qishr.cascara.common.util

Class Builder

java.lang.Object
        io.github.qishr.cascara.common.util.CommandLine.RegexTransformer.Builder

Enclosing Class:
    io.github.qishr.cascara.common.util.CommandLine.RegexTransformer


public static class Builder

Builder for creating RegexTransformer objects.

Constructor Summary

Constructor Description
Builder() Constructs an empty builder.
Builder(RegexTransformer old) Constructs a builder populated with the values from the specified RegexTransformer.

Method Summary

Modifier and Type Method Description
public Builder addPattern(String regex, String negativeReplacement, String synopsisReplacement) Adds the specified negative replacement and synopsis replacement for the specified regular expression.
public Builder removePattern(String regex) Removes the negative replacement and synopsis replacement for the specified regular expression.
public RegexTransformer build()

Method Details

addPattern

public Builder addPattern(String regex, String negativeReplacement, String synopsisReplacement)

Adds the specified negative replacement and synopsis replacement for the specified regular expression.For example, to add negative forms for short options:

Regular expressions for adding negative forms for short options

Regex
Negative Replacement
Synopsis Replacement
Comment


^-(\w)$
+$1
(+|-)$1
Converts -v to +v


^\+(\w)$
-$1
(+|-)$1
Converts -v to +v

Parameters:

regex - regular expression to match an option name

negativeReplacement - the replacement to use to generate a negative name when the option name matches

synopsisReplacement - the replacement to use to generate a documentation string when the option name matches

Returns:

this RegexTransformer for method chaining


removePattern

public Builder removePattern(String regex)

Removes the negative replacement and synopsis replacement for the specified regular expression.

Parameters:

regex - regular expression to remove

Returns:

this RegexTransformer for method chaining


build

public RegexTransformer build()