Package org.biouno.unochoice.util
Class Utils
- java.lang.Object
-
- org.biouno.unochoice.util.Utils
-
public class Utils extends Object
Utility methods.- Since:
- 0.23
- Author:
- Bruno P. Kinoshita
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringcreateRandomParameterName(String prefix, String suffix)Creates a random parameter name.static StringescapeDisabled(Object obj)Escapes the parameter value, removing the :disabled suffix.static StringescapeSelected(Object obj)Escapes the parameter value, removing the :selected suffix.static StringescapeSelectedAndDisabled(Object obj)Escapes the parameter value, removing the :selected and :disabled suffixes.static ProjectfindProjectByParameterUUID(String parameterUUID)Find the current project give its parameter UUID.static Set<org.jenkinsci.plugins.scriptler.config.Script>getAllScriptlerScripts()Returns all scriptler scripts available.static Map<BuildWrapper,List<ParameterDefinition>>getBuildWrapperParameterDefinitions(Project<?,?> project)Get parameter definitions associated withBuildWrappers of the givenProject.static Map<String,Object>getGlobalNodeProperties()Get a map with the global node properties.static Project<?,?>getProjectByName(String projectName)Deprecated.The choice is arbitrary if there are multiple matches; useItem.getFullName()andJenkins.getItemByFullName(String, Class)instead.static List<ParameterDefinition>getProjectParameterDefinitions(Project<?,?> project)Get the parameter definitions for the given project.static Map<String,String>getSystemEnv()Helped method to return the system environment variables.static booleanisDisabled(Object obj)Checks whether a parameter value contains the :disabled suffix, returningtrueif it does,falseotherwise.static booleanisSelected(Object obj)Checks whether a parameter value contains the :selected suffix, returningtrueif it does,falseotherwise.
-
-
-
Field Detail
-
LOGGER
protected static final Logger LOGGER
-
-
Method Detail
-
getAllScriptlerScripts
@Nonnull public static Set<org.jenkinsci.plugins.scriptler.config.Script> getAllScriptlerScripts()
Returns all scriptler scripts available.- Returns:
- all scriptler scripts available in Jenkins
-
isSelected
public static boolean isSelected(@Nullable Object obj)
Checks whether a parameter value contains the :selected suffix, returningtrueif it does,falseotherwise.- Parameters:
obj- parameter value- Returns:
trueif the parameter name contains the :selected suffixfalseotherwise.
-
escapeSelected
@Nonnull public static String escapeSelected(@Nullable Object obj)
Escapes the parameter value, removing the :selected suffix.- Parameters:
obj- parameter value- Returns:
- escaped parameter value
-
isDisabled
public static boolean isDisabled(@Nullable Object obj)
Checks whether a parameter value contains the :disabled suffix, returningtrueif it does,falseotherwise.- Parameters:
obj- parameter value- Returns:
trueif the parameter name contains the :disabled suffixfalseotherwise.
-
escapeDisabled
@Nonnull public static String escapeDisabled(@Nullable Object obj)
Escapes the parameter value, removing the :disabled suffix.- Parameters:
obj- parameter value- Returns:
- escaped parameter value
-
escapeSelectedAndDisabled
@Nonnull public static String escapeSelectedAndDisabled(@Nullable Object obj)
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
@Nonnull public static Map<String,String> 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
@CheckForNull public static Project<?,?> getProjectByName(@Nonnull String projectName)
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
nullif none with this name - Since:
- 1.3
-
findProjectByParameterUUID
@CheckForNull public static Project findProjectByParameterUUID(@Nonnull String parameterUUID)
Find the current project give its parameter UUID.- Parameters:
parameterUUID- parameter UUID- Returns:
nullif 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
@Nonnull public static Map<String,Object> 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 withBuildWrappers of the givenProject.- Parameters:
project- the project for which the parameter definitions should be found- Returns:
- Map
-
-