Record Class PropertyInitialiser
- Record Components:
property- the property whose initialiser the node is inaggregateParts- the body of the aggregate that property belongs to
An aggregate's property initialisers run in declaration order, in _i_init, BEFORE the constructor body. So while one runs, the only properties of the same type with a value are those declared earlier that have an initialiser of their own; and the object as a whole is never complete. Code that read a later property, a property set in the constructor, or called a method of the object, compiled clean and failed with a NullPointerException when the object was built (front-end audit FE32).
"The same type" is decided by where a property is declared: within the same aggregate body. A dynamic class declared inside an initialiser has its own body, so its properties are not the outer type's.
EnclosingPropertyInitialiser finds the one a node is in.
-
Constructor Summary
ConstructorsConstructorDescriptionPropertyInitialiser(EK9Parser.AggregatePropertyContext property, EK9Parser.AggregatePartsContext aggregateParts) Creates an instance of aPropertyInitialiserrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theaggregatePartsrecord component.booleanTrue if this property is declared in the same aggregate body as the initialiser - or, for a dynamic class, is one of its captures (declared in its capture list, just before its body).final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisDeclaredBefore(ISymbol candidate) True if this property is declared before the property whose initialiser this is - so its own initialiser, if it has one, has already run.property()Returns the value of thepropertyrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
PropertyInitialiser
public PropertyInitialiser(EK9Parser.AggregatePropertyContext property, EK9Parser.AggregatePartsContext aggregateParts) Creates an instance of aPropertyInitialiserrecord class.- Parameters:
property- the value for thepropertyrecord componentaggregateParts- the value for theaggregatePartsrecord component
-
-
Method Details
-
declares
True if this property is declared in the same aggregate body as the initialiser - or, for a dynamic class, is one of its captures (declared in its capture list, just before its body). A capture is declared before every property; whether it holds its value while the initialisers run is decided like any other property's: it does when the capture constructor is the only constructor, and otherwise it is a property declared with no value. -
isDeclaredBefore
True if this property is declared before the property whose initialiser this is - so its own initialiser, if it has one, has already run. The property being initialised is not declared before itself. -
toString
-
hashCode
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
property
-
aggregateParts
Returns the value of theaggregatePartsrecord component.- Returns:
- the value of the
aggregatePartsrecord component
-