Package org.opends.server.api
Class MonitorData
- java.lang.Object
-
- org.opends.server.api.MonitorData
-
@PublicAPI(stability=PRIVATE) public final class MonitorData extends Object implements Iterable<Attribute>
This class is used to hold monitoring data, i.e. a list of attributes. It provides convenient methods to easily build such data.Note:
Creating monitor entries may become a lot easier once we've migrated to the SDK Entry class:Entry entry = ...; entry.addAttribute("stringStat", "aString") .addAttribute("integerStat", 12345) .addAttribute("dnStat", DN.valueOf("dc=aDN");We could also envisage an annotation based approach where we determine the monitor content from annotated fields/methods in an object.
-
-
Constructor Summary
Constructors Constructor Description MonitorData()Constructor to use when the number of attributes to create is unknown.MonitorData(int expectedAttributesCount)Constructor that accepts the number of attributes to create.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String attrName, Object attrValue)Adds an attribute with the provided name and value.voidadd(String attrName, Collection<?> attrValues)Adds an attribute with the provided name and values.voidaddBean(Object bean, String attributesPrefix)Adds all the properties from the provided bean as attributes, prepending the provided prefix.voidaddIfNotNull(String attrName, Object attrValue)Adds an attribute with the provided name and value if the value is not null.Iterator<Attribute>iterator()intsize()Returns the number of attributes.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
MonitorData
public MonitorData()
Constructor to use when the number of attributes to create is unknown.
-
MonitorData
public MonitorData(int expectedAttributesCount)
Constructor that accepts the number of attributes to create.- Parameters:
expectedAttributesCount- number of attributes that will be added
-
-
Method Detail
-
add
public void add(String attrName, Object attrValue)
Adds an attribute with the provided name and value.- Parameters:
attrName- the attribute nameattrValue- the attribute value
-
addIfNotNull
public void addIfNotNull(String attrName, Object attrValue)
Adds an attribute with the provided name and value if the value is not null.- Parameters:
attrName- the attribute nameattrValue- the attribute value
-
add
public void add(String attrName, Collection<?> attrValues)
Adds an attribute with the provided name and values.- Parameters:
attrName- the attribute nameattrValues- the attribute values
-
addBean
public void addBean(Object bean, String attributesPrefix) throws ReflectiveOperationException
Adds all the properties from the provided bean as attributes, prepending the provided prefix.- Parameters:
bean- the bean from which to read the propertiesattributesPrefix- the prefix to prepend to the attributes read from the bean- Throws:
ReflectiveOperationException- if a problem occurs while reading the properties of the bean
-
size
public int size()
Returns the number of attributes.- Returns:
- the number of attributes
-
-