class ParamsStringBuilder extends AnyRef
Helper class for converting individual typed parameters to a single long string for passing to native libraries.
Example: new ParamsStringBuilder(prefix = "--", delimiter = "=") .append("--first_param=a") .appendParamValueIfNotThere("first_param", Option("a2")) .appendParamValueIfNotThere("second_param", Option("b")) .appendParamValueIfNotThere("third_param", None) .result
result == "--first_param=a --second_param=b"
This utility mimics a traditional StringBuilder, where you append parts and ask for the final result() at the end. Each parameter appended is tracked and can be compared against the current string, to both avoid duplicates and provide an override mechanism. The first param added is considered the primary one to not be replaced.
Use 'append' to add an unchecked string directly to end of current string.
Use ParamsSet to create encapsulated subsets of params that can be incorporated into the parent ParamsStringBuilder.
There is also integration with the SparkML Params system. Construct with a parent Params object and use the methods with Param arguments.
- Alphabetic
- By Inheritance
- ParamsStringBuilder
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new ParamsStringBuilder(parent: Params, prefix: String, delimiter: String)
- new ParamsStringBuilder(prefix: String = "", delimiter: String = "=")
-
new
ParamsStringBuilder(parent: Option[Params], prefix: String, delimiter: String)
- parent
Optional parent Params instance to validate each Param against.
- prefix
Optional prefix to put before parameter names (e.g. "--"). Defaults to none.
- delimiter
Optional delimiter to put between names and values (e.g. "="). Defaults to "=".
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
append(str: String): ParamsStringBuilder
Direct append a string with no checking of existing params.
Direct append a string with no checking of existing params.
- str
The string to add.
-
def
appendParamFlagIfNotThere(name: String): ParamsStringBuilder
Add a parameter name to the end of the current string.
Add a parameter name to the end of the current string. (i.e. a param that does not have a value)
-
def
appendParamGroup(paramGroup: ParamGroup, condition: Boolean): ParamsStringBuilder
Add a parameter group to the end of the current string conditionally.
Add a parameter group to the end of the current string conditionally.
- paramGroup
The ParamGroup to add.
- condition
Whether to add the group or not.
-
def
appendParamGroup(paramGroup: ParamGroup): ParamsStringBuilder
Add a parameter group to the end of the current string.
Add a parameter group to the end of the current string.
- paramGroup
The ParamGroup to add.
- def appendParamList[T](name: String, values: Array[T]): ParamsStringBuilder
-
def
appendParamListIfNotThere[T](name: String, values: Array[T]): ParamsStringBuilder
Add a parameter name-list pair to the end of the current string.
Add a parameter name-list pair to the end of the current string. Values will be comma-delimited.
- values
The Array of values. Note that if the array is empty, nothing will be appended to string.
-
def
appendParamValueIfNotThere[T](optionLong: String, param: Option[T]): ParamsStringBuilder
Add a parameter name-value pair to the end of the current string.
Add a parameter name-value pair to the end of the current string.
- optionLong
Long name of the parameter. Will be used if it is not already set.
- param
The Option object with the value. Note that if this is None, nothing will be appended to string.
-
def
appendParamValueIfNotThere[T](optionShort: String, optionLong: String, param: Param[T]): ParamsStringBuilder
Add a parameter name-value pair to the end of the current string.
Add a parameter name-value pair to the end of the current string.
- optionShort
Short name of the parameter (only used to check against existing params).
- optionLong
Long name of the parameter. Will be used if it is not already set.
- param
The Param object with the value. Note that if this is not set, nothing will be appended to string.
-
def
appendRepeatableParamIfNotThere[T](optionShort: String, optionLong: String, values: Array[T]): ParamsStringBuilder
Add a parameter that can be repeated, once for each element in the array (e.g.
Add a parameter that can be repeated, once for each element in the array (e.g. "-q aa -q bb")
- optionLong
Long name of the parameter. Will be used if it is not already set.
- values
The Array of values. Note that if the array is empty, nothing will be appended to string.
-
def
appendRepeatableParamIfNotThere[T](optionShort: String, optionLong: String, param: Param[T]): ParamsStringBuilder
Add a parameter name-value pair for each array element to the end of the current string (e.g.
Add a parameter name-value pair for each array element to the end of the current string (e.g. "-q aa -q bb").
- optionShort
Short name of the parameter (only used to check against existing params).
- optionLong
Long name of the parameter. Will be used if it is not already set.
- param
The Param object with the value. Note that if this is not set, nothing will be appended to string.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def result(): String
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()