Package cs1302.tracer.model.modern
Record Class HeapObject
java.lang.Object
java.lang.Record
cs1302.tracer.model.modern.HeapObject
- Record Components:
id- The unique reference ID of this heap object.type- The runtime or declared type of the object.kind- The category of heap object: "object", "array", "string", "lambda", "box", or "color".fields- The list of instance fields for objects.elements- The list of element values for arrays.value- The scalar string or boxed value.sam- The single abstract method implementation for lambdas.
public record HeapObject(long id, String type, String kind, List<Variable> fields, List<Object> elements, Object value, String sam)
extends Record
Represents a typed heap object in the modern trace format.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionelements()Returns the value of theelementsrecord component.final booleanIndicates whether some other object is "equal to" this one.fields()Returns the value of thefieldsrecord component.final inthashCode()Returns a hash code value for this object.longid()Returns the value of theidrecord component.kind()Returns the value of thekindrecord component.static HeapObjectFactory method for arrays.static HeapObjectFactory method for boxed primitives.static HeapObjectFactory method for colors.static HeapObjectFactory method for lambdas.static HeapObjectFactory method for general instance objects.static HeapObjectFactory method for strings defaulting to java.lang.String.static HeapObjectFactory method for strings with custom type qualification.sam()Returns the value of thesamrecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
HeapObject
public HeapObject(long id, String type, String kind, List<Variable> fields, List<Object> elements, Object value, String sam) Creates an instance of aHeapObjectrecord class.- Parameters:
id- the value for theidrecord componenttype- the value for thetyperecord componentkind- the value for thekindrecord componentfields- the value for thefieldsrecord componentelements- the value for theelementsrecord componentvalue- the value for thevaluerecord componentsam- the value for thesamrecord component
-
-
Method Details
-
ofObject
Factory method for general instance objects.- Parameters:
id- The heap object ID.type- The object type.fields- The object fields.- Returns:
- A new HeapObject instance for an object.
-
ofArray
Factory method for arrays.- Parameters:
id- The heap object ID.type- The array component or array type.elements- The array elements.- Returns:
- A new HeapObject instance for an array.
-
ofString
Factory method for strings with custom type qualification.- Parameters:
id- The heap object ID.type- The string type name.value- The string value.- Returns:
- A new HeapObject instance for a string.
-
ofString
Factory method for strings defaulting to java.lang.String.- Parameters:
id- The heap object ID.value- The string value.- Returns:
- A new HeapObject instance for a string.
-
ofBox
Factory method for boxed primitives.- Parameters:
id- The heap object ID.type- The boxed type.value- The primitive value.- Returns:
- A new HeapObject instance for a box.
-
ofLambda
Factory method for lambdas.- Parameters:
id- The heap object ID.type- The functional interface type.sam- The single abstract method implementation.- Returns:
- A new HeapObject instance for a lambda.
-
ofColor
Factory method for colors.- Parameters:
id- The heap object ID.type- The color type name.value- The hex color string.- Returns:
- A new HeapObject instance for a color.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
id
@SerializedName("id") public long id()Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
kind
Returns the value of thekindrecord component.- Returns:
- the value of the
kindrecord component
-
fields
Returns the value of thefieldsrecord component.- Returns:
- the value of the
fieldsrecord component
-
elements
Returns the value of theelementsrecord component.- Returns:
- the value of the
elementsrecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
sam
Returns the value of thesamrecord component.- Returns:
- the value of the
samrecord component
-