Class SbkUtils
java.lang.Object
io.sbk.utils.SbkUtils
Utility methods for inspecting, filtering, and merging SBK arguments.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConverts option/value argument pairs to an ordered map.static StringgetArgValue(String[] args, String argName) Finds the value following an option.static StringgetClassName(String[] args) Returns the selected storage class name.static @NotNull StringReturn the normalized home of the running JVM.static @NotNull StringgetJavaSelectionSource(Map<String, String> environment, String runtimeHome) Identify how the launcher selected the running JVM.static StringgetLoggerName(String[] args) Returns the selected logger name.static @NotNull StringReturns the operating-system name, version, and architecture reported by the JVM.static booleanTests whether an argument is present.static booleanTests whether the help option is present.static booleanhasVersion(String[] args) Tests whether either version option is present.static voidLog the running JVM version, resolved home, executable, and launcher selection source.static String[]Converts ordered option/value mappings to an argument array.static String[]Merges two option/value arrays, with the second array taking precedence.static booleanparseBooleanOption(String option, String value) Parse a command-line boolean without silently treating a typo as false.static @NotNull String[]redactOptionValues(String[] args, String[] sensitiveOptions) Return a copy of command-line arguments with values belonging to sensitive options replaced by a fixed mask.static @NotNull String[]redactSensitiveOptionValues(String[] args) Return a copy of SBK arguments with values for commonly used credential options replaced by a fixed mask.static @NotNull String[]removeOptionArgs(String[] args, String[] opts) Removes each named option once while retaining other arguments.static @NotNull String[]removeOptionArgsAndValues(String[] args, String[] opts) Removes each named option and its following value once.
-
Constructor Details
-
SbkUtils
public SbkUtils()Creates an SBK argument utility.
-
-
Method Details
-
redactOptionValues
@NotNull public static @NotNull String[] redactOptionValues(String[] args, String[] sensitiveOptions) Return a copy of command-line arguments with values belonging to sensitive options replaced by a fixed mask. Both-option valueand--option=valueforms are supported, without modifying the source array.- Parameters:
args- command-line argumentssensitiveOptions- sensitive option names, with or without leading dashes- Returns:
- copied arguments with sensitive values redacted
-
redactSensitiveOptionValues
-
parseBooleanOption
Parse a command-line boolean without silently treating a typo as false.- Parameters:
option- option name used in an actionable error messagevalue- configured option value- Returns:
- parsed boolean
- Throws:
IllegalArgumentException- if the value is nottrueorfalse
-
getOperatingSystemDetails
Returns the operating-system name, version, and architecture reported by the JVM.- Returns:
- operating-system details suitable for startup diagnostics
-
logJavaRuntimeDetails
public static void logJavaRuntimeDetails()Log the running JVM version, resolved home, executable, and launcher selection source. -
getJavaRuntimeHome
Return the normalized home of the running JVM.- Returns:
- normalized Java runtime home
-
getJavaSelectionSource
@NotNull public static @NotNull String getJavaSelectionSource(Map<String, String> environment, String runtimeHome) Identify how the launcher selected the running JVM.- Parameters:
environment- process environmentruntimeHome- normalized home of the running JVM- Returns:
- human-readable Java selection source
-
removeOptionArgsAndValues
-
removeOptionArgs
-
getArgValue
-
getClassName
-
getLoggerName
-
hasArg
-
hasHelp
Tests whether the help option is present.- Parameters:
args- source arguments- Returns:
truewhen help was requested
-
hasVersion
Tests whether either version option is present.- Parameters:
args- source arguments- Returns:
truewhen version information was requested
-
mapToArgs
-
argsToMap
-
mergeArgs
-