Class Utils


  • public final class Utils
    extends Object
    Defines common methods that are used for the whole project.
    • Method Detail

      • validateChartAttributes

        public static int validateChartAttributes​(String attribute,
                                                  int defaultValue)
        Validate chart attributes returning a valid value to the object.
        Parameters:
        attribute - the attribute: width, height, number of days
        defaultValue - default value for the attribute
        Returns:
        int attribute valid value
      • getLastDate

        public static Calendar getLastDate​(List<Job<?,​?>> jobs)
        For the given list of jobs, this will search all jobs and return the last run date of all.
        Parameters:
        jobs - a list of jobs from the DashBoard Portlet view
        Returns:
        LocalDate the last date of all jobs that belongs to Dashboard View.
      • roundFloat

        public static float roundFloat​(int scale,
                                       RoundingMode roundingMode,
                                       float value)
        Method for rounding float values according to the requested mode.
        Parameters:
        scale - the rounding scale
        roundingMode - the rounding direction @see java.math.RoundingMode
        value - the value to be rounded
        Returns:
        the rounded value
      • nthOccurrence

        public static int nthOccurrence​(String str,
                                        char c,
                                        int n)
      • applyLogicalAnd

        public static Result applyLogicalAnd​(Result op1,
                                             Result op2)
        Logical AND operation of Jenkins build results: Success AND Success = Success Unstable AND Unstable = Unstable Failure AND Failure = Failure X AND Failure = Failure, Failure AND X = Failure, X = Success/Unstable/Failure Y AND Unstable = Unstable, Unstable AND Y = Unstable, Y = Success/Unstable
        Parameters:
        op1 - first result
        op2 - second result
        Returns:
        Logical AND operation of op1 AND op2