com.espertech.esper.metrics.codahale_metrics.metrics.core
Class MetricName

java.lang.Object
  extended by com.espertech.esper.metrics.codahale_metrics.metrics.core.MetricName
All Implemented Interfaces:
java.lang.Comparable<MetricName>

public class MetricName
extends java.lang.Object
implements java.lang.Comparable<MetricName>

A value class encapsulating a metric's owning class and name.


Constructor Summary
MetricName(java.lang.Class<?> klass, java.lang.String name)
          Creates a new MetricName without a scope.
MetricName(java.lang.Class<?> klass, java.lang.String name, java.lang.String scope)
          Creates a new MetricName without a scope.
MetricName(java.lang.String group, java.lang.String type, java.lang.String name)
          Creates a new MetricName without a scope.
MetricName(java.lang.String group, java.lang.String type, java.lang.String name, java.lang.String scope)
          Creates a new MetricName without a scope.
MetricName(java.lang.String group, java.lang.String type, java.lang.String name, java.lang.String scope, java.lang.String mBeanName)
          Creates a new MetricName without a scope.
 
Method Summary
static java.lang.String chooseGroup(java.lang.String group, java.lang.Class<?> klass)
          If the group is empty, use the package name of the given class.
static java.lang.String chooseName(java.lang.String name, java.lang.reflect.Method method)
          If name is empty, use the name of the given method.
static java.lang.String chooseType(java.lang.String type, java.lang.Class<?> klass)
          If the type is empty, use the simple name of the given class.
 int compareTo(MetricName o)
           
 boolean equals(java.lang.Object o)
           
 java.lang.String getGroup()
          Returns the group to which the Metric belongs.
 java.lang.String getMBeanName()
          Returns the MBean name for the Metric identified by this metric name.
 java.lang.String getName()
          Returns the name of the Metric.
 java.lang.String getScope()
          Returns the scope of the Metric.
 java.lang.String getType()
          Returns the type to which the Metric belongs.
 int hashCode()
           
 boolean hasScope()
          Returns true if the Metric has a scope, false otherwise.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetricName

public MetricName(java.lang.Class<?> klass,
                  java.lang.String name)
Creates a new MetricName without a scope.

Parameters:
klass - the Class to which the Metric belongs
name - the name of the Metric

MetricName

public MetricName(java.lang.String group,
                  java.lang.String type,
                  java.lang.String name)
Creates a new MetricName without a scope.

Parameters:
group - the group to which the Metric belongs
type - the type to which the Metric belongs
name - the name of the Metric

MetricName

public MetricName(java.lang.Class<?> klass,
                  java.lang.String name,
                  java.lang.String scope)
Creates a new MetricName without a scope.

Parameters:
klass - the Class to which the Metric belongs
name - the name of the Metric
scope - the scope of the Metric

MetricName

public MetricName(java.lang.String group,
                  java.lang.String type,
                  java.lang.String name,
                  java.lang.String scope)
Creates a new MetricName without a scope.

Parameters:
group - the group to which the Metric belongs
type - the type to which the Metric belongs
name - the name of the Metric
scope - the scope of the Metric

MetricName

public MetricName(java.lang.String group,
                  java.lang.String type,
                  java.lang.String name,
                  java.lang.String scope,
                  java.lang.String mBeanName)
Creates a new MetricName without a scope.

Parameters:
group - the group to which the Metric belongs
type - the type to which the Metric belongs
name - the name of the Metric
scope - the scope of the Metric
mBeanName - the 'ObjectName', represented as a string, to use when registering the MBean.
Method Detail

getGroup

public java.lang.String getGroup()
Returns the group to which the Metric belongs. For class-based metrics, this will be the package name of the Class to which the Metric belongs.

Returns:
the group to which the Metric belongs

getType

public java.lang.String getType()
Returns the type to which the Metric belongs. For class-based metrics, this will be the simple class name of the Class to which the Metric belongs.

Returns:
the type to which the Metric belongs

getName

public java.lang.String getName()
Returns the name of the Metric.

Returns:
the name of the Metric

getScope

public java.lang.String getScope()
Returns the scope of the Metric.

Returns:
the scope of the Metric

hasScope

public boolean hasScope()
Returns true if the Metric has a scope, false otherwise.

Returns:
true if the Metric has a scope

getMBeanName

public java.lang.String getMBeanName()
Returns the MBean name for the Metric identified by this metric name.

Returns:
the MBean name

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(MetricName o)
Specified by:
compareTo in interface java.lang.Comparable<MetricName>

chooseGroup

public static java.lang.String chooseGroup(java.lang.String group,
                                           java.lang.Class<?> klass)
If the group is empty, use the package name of the given class. Otherwise use group

Parameters:
group - The group to use by default
klass - The class being tracked
Returns:
a group for the metric

chooseType

public static java.lang.String chooseType(java.lang.String type,
                                          java.lang.Class<?> klass)
If the type is empty, use the simple name of the given class. Otherwise use type

Parameters:
type - The type to use by default
klass - The class being tracked
Returns:
a type for the metric

chooseName

public static java.lang.String chooseName(java.lang.String name,
                                          java.lang.reflect.Method method)
If name is empty, use the name of the given method. Otherwise use name

Parameters:
name - The name to use by default
method - The method being tracked
Returns:
a name for the metric

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com