Package com.facilita.fc.runtime
Class Metric
- java.lang.Object
-
- com.facilita.fc.runtime.Metric
-
public class Metric extends java.lang.Object
Represents a user-defined metric that can be recorded by eggPlant Performance.
-
-
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()
Returnstrue
if the metric passed.java.lang.String
toString()
Returns aString
that represents the currentMetric
.int
value()
Gets the value of the metric.
-
-
-
Constructor Detail
-
Metric
public Metric(java.lang.String name, int value, boolean pass) throws BadValueException
Creates aMetric
object, specifying whether the metric passed or failed.- Parameters:
name
- the name of the metricvalue
- the value associated with the metricpass
- 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 aMetric
object.- Parameters:
name
- the name of the metricvalue
- 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()
Returnstrue
if the metric passed.- Returns:
true
if the metric passed
-
toString
public java.lang.String toString()
Returns aString
that represents the currentMetric
.The metric is represented as a
name=value
pair. For failed metrics,",F"
is appended.e.g.
"myMetric=12,F"
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a
String
representation of the curentMetric
-
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
- Thetext
was invalid
-
-