Package org.biouno.unochoice.util
Class Utils
java.lang.Object
org.biouno.unochoice.util.Utils
Utility methods.
- Since:
- 0.23
- Author:
- Bruno P. Kinoshita
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
createRandomParameterName
(String prefix, String suffix) Creates a random parameter name.static String
escapeDisabled
(Object obj) Escapes the parameter value, removing the :disabled suffix.static String
escapeSelected
(Object obj) Escapes the parameter value, removing the :selected suffix.static String
Escapes the parameter value, removing the :selected and :disabled suffixes.static Project
findProjectByParameterUUID
(String parameterUUID) Find the current project give its parameter UUID.static Map<BuildWrapper,
List<ParameterDefinition>> getBuildWrapperParameterDefinitions
(Project<?, ?> project) Get parameter definitions associated withBuildWrapper
s of the givenProject
.Get a map with the global node properties.static Project<?,
?> getProjectByName
(String projectName) Deprecated.static List<ParameterDefinition>
getProjectParameterDefinitions
(Project<?, ?> project) Get the parameter definitions for the given project.Helped method to return the system environment variables.static boolean
isDisabled
(Object obj) Checks whether a parameter value contains the :disabled suffix, returningtrue
if it does,false
otherwise.static boolean
isSelected
(Object obj) Checks whether a parameter value contains the :selected suffix, returningtrue
if it does,false
otherwise.
-
Field Details
-
LOGGER
-
-
Method Details
-
isSelected
Checks whether a parameter value contains the :selected suffix, returningtrue
if it does,false
otherwise.- Parameters:
obj
- parameter value- Returns:
true
if the parameter name contains the :selected suffixfalse
otherwise.
-
escapeSelected
Escapes the parameter value, removing the :selected suffix.- Parameters:
obj
- parameter value- Returns:
- escaped parameter value
-
isDisabled
Checks whether a parameter value contains the :disabled suffix, returningtrue
if it does,false
otherwise.- Parameters:
obj
- parameter value- Returns:
true
if the parameter name contains the :disabled suffixfalse
otherwise.
-
escapeDisabled
Escapes the parameter value, removing the :disabled suffix.- Parameters:
obj
- parameter value- Returns:
- escaped parameter value
-
escapeSelectedAndDisabled
Escapes the parameter value, removing the :selected and :disabled suffixes.- Parameters:
obj
- parameter value- Returns:
- escaped parameter value
-
createRandomParameterName
@NonNull public static String createRandomParameterName(@Nullable String prefix, @Nullable String suffix) Creates a random parameter name.- Parameters:
prefix
- parameter prefixsuffix
- parameter suffix- Returns:
- random parameter name
-
getSystemEnv
Helped method to return the system environment variables. The main advantage over calling the System.getenv method directly, is that we can mock this call (System is final).- Returns:
- System environment variables as map
-
getProjectByName
Deprecated.The choice is arbitrary if there are multiple matches; useItem.getFullName()
andJenkins.getItemByFullName(String, Class)
instead.Get project in Jenkins given its name.- Parameters:
projectName
- project name in Jenkins- Returns:
- Project or
null
if none with this name - Since:
- 1.3
-
findProjectByParameterUUID
Find the current project give its parameter UUID.- Parameters:
parameterUUID
- parameter UUID- Returns:
null
if the current project cannot be found- Since:
- 1.3
-
getProjectParameterDefinitions
@NonNull public static List<ParameterDefinition> getProjectParameterDefinitions(@NonNull Project<?, ?> project) Get the parameter definitions for the given project.- Parameters:
project
- the project for which the parameter definitions should be found- Returns:
- parameter definitions or an empty list
- Since:
- 1.3
-
getGlobalNodeProperties
Get a map with the global node properties.- Returns:
- map with global node properties
- Since:
- 1.6
-
getBuildWrapperParameterDefinitions
@NonNull public static Map<BuildWrapper,List<ParameterDefinition>> getBuildWrapperParameterDefinitions(@NonNull Project<?, ?> project) Get parameter definitions associated withBuildWrapper
s of the givenProject
.- Parameters:
project
- the project for which the parameter definitions should be found- Returns:
- Map
-
Item.getFullName()
andJenkins.getItemByFullName(String, Class)
instead.