ValueHolder.kt
TLDR
The provided file defines a Kotlin sealed class ValueHolder
, which represents a value in the heap dump. It includes several data classes for different types of values, such as ReferenceHolder
, BooleanHolder
, CharHolder
, and so on.
Classes
ValueHolder
This sealed class represents a value in the heap dump. It includes the following nested data classes:
-
ReferenceHolder
: Represents a reference value in the heap dump. It contains avalue
property of typeLong
, which represents the reference value. It also has aisNull
property that returnstrue
if the reference value isNULL_REFERENCE
(which is defined as 0L in the companion object). -
BooleanHolder
: Represents a boolean value in the heap dump. It contains avalue
property of typeBoolean
, which represents the boolean value. -
CharHolder
: Represents a char value in the heap dump. It contains avalue
property of typeChar
, which represents the char value. -
FloatHolder
: Represents a float value in the heap dump. It contains avalue
property of typeFloat
, which represents the float value. -
DoubleHolder
: Represents a double value in the heap dump. It contains avalue
property of typeDouble
, which represents the double value. -
ByteHolder
: Represents a byte value in the heap dump. It contains avalue
property of typeByte
, which represents the byte value. -
ShortHolder
: Represents a short value in the heap dump. It contains avalue
property of typeShort
, which represents the short value. -
IntHolder
: Represents an int value in the heap dump. It contains avalue
property of typeInt
, which represents the int value. -
LongHolder
: Represents a long value in the heap dump. It contains avalue
property of typeLong
, which represents the long value.
Companion object
The companion object contains a single property:
-
NULL_REFERENCE
: Represents the value of a null reference in the heap dump, which is defined as 0L.
package shark
import shark.ValueHolder.ReferenceHolder
/**
* A value in the heap dump, which can be a [ReferenceHolder] or
* a primitive type.
*/
sealed class ValueHolder {
data class ReferenceHolder(val value: Long) : ValueHolder() {
val isNull
get() = value == NULL_REFERENCE
}
data class BooleanHolder(val value: Boolean) : ValueHolder()
data class CharHolder(val value: Char) : ValueHolder()
data class FloatHolder(val value: Float) : ValueHolder()
data class DoubleHolder(val value: Double) : ValueHolder()
data class ByteHolder(val value: Byte) : ValueHolder()
data class ShortHolder(val value: Short) : ValueHolder()
data class IntHolder(val value: Int) : ValueHolder()
data class LongHolder(val value: Long) : ValueHolder()
companion object {
const val NULL_REFERENCE = 0L
}
}