Class Metric


  • public class Metric
    extends java.lang.Object
    Represents a user-defined metric that can be recorded by eggPlant Performance.
    • Constructor Summary

      Constructors 
      Constructor Description
      Metric​(java.lang.String name, int value)
      Creates a Metric object.
      Metric​(java.lang.String name, int value, boolean pass)
      Creates a Metric object, specifying whether the metric passed or failed.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Metric fromString​(java.lang.String text)
      Initializes an instance of the Metric class, from the passed String value.
      java.lang.String name()
      Gets the name of the metric.
      boolean pass()
      Returns true if the metric passed.
      java.lang.String toString()
      Returns a String that represents the current Metric.
      int value()
      Gets the value of the metric.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Metric

        public Metric​(java.lang.String name,
                      int value,
                      boolean pass)
               throws BadValueException
        Creates a Metric object, specifying whether the metric passed or failed.
        Parameters:
        name - the name of the metric
        value - the value associated with the metric
        pass - whether the metric passed or failed
        Throws:
        BadValueException - the name of the metric is not valid
      • Metric

        public Metric​(java.lang.String name,
                      int value)
               throws BadValueException
        Creates a Metric object.
        Parameters:
        name - the name of the metric
        value - the value associated with the metric
        Throws:
        BadValueException - the name of the metric is not valid
    • Method Detail

      • name

        public java.lang.String name()
        Gets the name of the metric.
        Returns:
        the name of the metric
      • value

        public int value()
        Gets the value of the metric.
        Returns:
        the value of the metric
      • pass

        public boolean pass()
        Returns true if the metric passed.
        Returns:
        true if the metric passed
      • toString

        public java.lang.String toString()
        Returns a String that represents the current Metric.

        The metric is represented as a name=value pair. For failed metrics, ",F" is appended.

        e.g. "myMetric=12,F"

        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation of the curent Metric
      • fromString

        public static Metric fromString​(java.lang.String text)
                                 throws BadValueException
        Initializes an instance of the Metric class, from the passed String value.

        Takes a string in the following format and constructs a Metric instance:
        "myMetric01=12,F"

        For pass values of true omit the ",F" from the string.
        "myMetric02=34"

        The following example demonstrates constructing a Metric object from a string:

        string metricText = "myMetric01=12,F";
        Metric myMetric = Metric.FromString(metricText);

        Parameters:
        text - - String
        Returns:
        Metric
        Throws:
        BadValueException - The text was invalid