Class Metric.Builder

  • Enclosing class:
    Metric<G extends java.io.Serializable>

    public static final class Metric.Builder
    extends java.lang.Object
    Metric.Builder is used to create metric definitions. It must be preferred to creating new instances of the Metric class directly.
    Since:
    2.7
    • Constructor Detail

      • Builder

        public Builder​(java.lang.String key,
                       java.lang.String name,
                       Metric.ValueType type)
        Creates a new Metric.Builder object.
        Parameters:
        key - the metric key, should be unique among all metrics
        name - the metric name
        type - the metric type
    • Method Detail

      • setDescription

        public Metric.Builder setDescription​(java.lang.String d)
        Sets the metric description.
        Parameters:
        d - the description
        Returns:
        the builder
      • setDirection

        public Metric.Builder setDirection​(java.lang.Integer d)
        Sets the metric direction (used for numeric values only), which is used in the Web UI to show if the trend of a metric is good or not.
        • Metric.DIRECTION_WORST: indicates that an increase of the metric value is not a good thing (example: the complexity of a function)
        • Metric.DIRECTION_BETTER: indicates that an increase of the metric value is a good thing (example: the code coverage of a function)
        • Metric.DIRECTION_NONE: indicates that the variation of the metric value is neither good nor bad (example: number of files).
        Metric.DIRECTION_NONE is the default value.
        Parameters:
        d - the direction
        Returns:
        the builder
        See Also:
        Metric.DIRECTION_WORST, Metric.DIRECTION_BETTER, Metric.DIRECTION_NONE
      • setQualitative

        public Metric.Builder setQualitative​(java.lang.Boolean b)
        Sets whether the metric is qualitative or not. Default value is false.
        If set to true, then variations of this metric will be highlighted in the Web UI (for instance, trend icons will be red or green instead of default grey).
        Parameters:
        b - Boolean.TRUE if the metric is qualitative
        Returns:
        the builder
      • setDomain

        public Metric.Builder setDomain​(java.lang.String d)
        Sets the domain for the metric (General, Complexity...). This is used to group metrics in the Web UI.
        By default, the metric belongs to no specific domain.
        Parameters:
        d - the domain
        Returns:
        the builder
      • setWorstValue

        public Metric.Builder setWorstValue​(java.lang.Double d)
        Sets the worst value that the metric can get (example: 0.0 for code coverage). No worst value is set by default.
        Parameters:
        d - the worst value
        Returns:
        the builder
      • setBestValue

        public Metric.Builder setBestValue​(java.lang.Double d)
        Sets the best value that the metric can get (example: 100.0 for code coverage). No best value is set by default.
        Resources would be hidden on drilldown page, if the value of measure equals to best value.
        Parameters:
        d - the best value
        Returns:
        the builder
      • setOptimizedBestValue

        public Metric.Builder setOptimizedBestValue​(boolean b)
        Specifies whether file-level measures that equal to the defined best value are stored or not. Default is false.
        Example with the metric that stores the number of violation (CoreMetrics.VIOLATIONS): if a file has no violation, then the value '0' won't be stored in the database.
        Parameters:
        b - true if the measures must not be stored when they equal to the best value
        Returns:
        the builder
      • setHidden

        public Metric.Builder setHidden​(boolean b)
        Sets whether the metric should be hidden in Web UI (e.g. in Time Machine). Default is false.
        Parameters:
        b - true if the metric should be hidden.
        Returns:
        the builder
      • setUserManaged

        public Metric.Builder setUserManaged​(boolean b)
        Specifies whether this metric can be edited online in the "Manual measures" page. Default is false.
        Parameters:
        b - true if the metric can be edited online.
        Returns:
        the builder
        Since:
        2.10
      • setDeleteHistoricalData

        public Metric.Builder setDeleteHistoricalData​(boolean b)
        Specifies whether measures from the past can be automatically deleted to minimize database volume.
        By default, historical data are kept.
        Parameters:
        b - true if measures from the past can be deleted automatically.
        Returns:
        the builder
        Since:
        2.14
      • create

        public <G extends java.io.Serializable> Metric<G> create()
        Creates a new metric definition based on the properties set on this metric builder.
        Returns:
        a new Metric object