Class Utils

java.lang.Object
org.biouno.unochoice.util.Utils

public class Utils extends Object
Utility methods.
Since:
0.23
Author:
Bruno P. Kinoshita
  • Field Details

    • LOGGER

      protected static final Logger LOGGER
  • Method Details

    • isSelected

      public static boolean isSelected(@Nullable Object obj)
      Checks whether a parameter value contains the :selected suffix, returning true if it does, false otherwise.
      Parameters:
      obj - parameter value
      Returns:
      true if the parameter name contains the :selected suffix false otherwise.
    • 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, returning true if it does, false otherwise.
      Parameters:
      obj - parameter value
      Returns:
      true if the parameter name contains the :disabled suffix false otherwise.
    • 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 prefix
      suffix - 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

      @Deprecated @CheckForNull public static Project<?,?> getProjectByName(@NonNull String projectName)
      Deprecated.
      The choice is arbitrary if there are multiple matches; use Item.getFullName() and Jenkins.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

      @CheckForNull public static Project findProjectByParameterUUID(@NonNull String parameterUUID)
      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

      @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 with BuildWrappers of the given Project.
      Parameters:
      project - the project for which the parameter definitions should be found
      Returns:
      Map