- java.lang.Object
-
- jdk.jfr.consumer.RecordedObject
-
- Direct Known Subclasses:
RecordedClass
,RecordedClassLoader
,RecordedEvent
,RecordedFrame
,RecordedMethod
,RecordedStackTrace
,RecordedThread
,RecordedThreadGroup
public class RecordedObject extends Object
A complex data type that consists of one or more fields.- Since:
- 9
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ValueDescriptor>
getFields()
Returns an immutable list of the fields for this object.<T> T
getValue(String name)
Returns the value of the field with the given name.boolean
hasField(String name)
Returnstrue
if a field with given name exists,false
otherwise.String
toString()
Returns a textual representation of this object.
-
-
-
Method Detail
-
hasField
public boolean hasField(String name)
Returnstrue
if a field with given name exists,false
otherwise.- Parameters:
name
- name of the field- Returns:
true
if the field exists,false
otherwise.- See Also:
getFields()
-
getValue
public final <T> T getValue(String name)
Returns the value of the field with the given name.The return type may be a primitive type or a subclass of
RecordedObject
.Callers of this method should not assume that a field will always remain, for instance a field may be removed in a future JDK version.
It's possible to index into a nested object using
"."
, for instance"thread.group.parent.name
".Example,
if (event.hasField("intValue") { int intValue = event.getValue("intValue"); System.out.println("Int value: " + intValue); } if (event.hasField("objectClass") { RecordedClass clazz = event.getValue("objectClass"); System.out.println("Class name: " + clazz.getName()); } if (event.hasField("sampledThread") { RecordedThread sampledThread= event.getValue("sampledThread"); System.out.println("Sampled thread: " + sampledThread.getName()); }
- Type Parameters:
T
- the return type- Parameters:
name
- name of the field to get, notnull
- Returns:
- value the value, can be
null
- Throws:
IllegalArgumentException
- if there is no field calledname
.- See Also:
hasField(String)
-
getFields
public List<ValueDescriptor> getFields()
Returns an immutable list of the fields for this object.- Returns:
- the fields, not
null
-
-