Class Metric<T extends Number>

  • Type Parameters:
    T - the value type
    Direct Known Subclasses:
    Delta

    public class Metric<T extends Number>
    extends Object
    Immutable class that can be used to hold any arbitrary system measurement value (a named numeric value with a timestamp). For example a metric might record the number of active connections to a server, or the temperature of a meeting room.
    • Constructor Detail

      • Metric

        public Metric​(String name,
                      T value)
        Create a new Metric instance for the current time.
        Parameters:
        name - the name of the metric
        value - the value of the metric
      • Metric

        public Metric​(String name,
                      T value,
                      Date timestamp)
        Create a new Metric instance.
        Parameters:
        name - the name of the metric
        value - the value of the metric
        timestamp - the timestamp for the metric
    • Method Detail

      • getName

        public String getName()
        Returns the name of the metric.
        Returns:
        the name
      • getValue

        public T getValue()
        Returns the value of the metric.
        Returns:
        the value
      • increment

        public Metric<Longincrement​(int amount)
        Create a new Metric with an incremented value.
        Parameters:
        amount - the amount that the new metric will differ from this one
        Returns:
        a new Metric instance
      • set

        public <S extends NumberMetric<S> set​(S value)
        Create a new Metric with a different value.
        Type Parameters:
        S - the metric value type
        Parameters:
        value - the value of the new metric
        Returns:
        a new Metric instance