Package org.ek9lang.compiler
Record Class ResolvedOrDefineResult
java.lang.Object
java.lang.Record
org.ek9lang.compiler.ResolvedOrDefineResult
public record ResolvedOrDefineResult(Optional<PossibleGenericSymbol> symbol, boolean newlyDefined)
extends Record
Mainly used in the CompilableProgram for resolving or defining a new Parameterized type.
The main issue with defining a Parameterized type is that it must be done in a single operation
inside a lock.
So when we encounter the need for a new parameterized generic type, the appropriate component
creates one and then calls on the CompilableProgram to either 'resolve' one that matches, or use
the one that has been passed in to 'define' that parameterized type. This is because there can and will be
multiple threads running through different sources. They may each find the need for a 'List of String',
the first one gets to define and the rest resolve, hence the need for a lock with a single operation.
But the calling code needs to 'know' if the returned symbol has been newly defined. This is because the
initial creation of the parameterized type will only be a minimal outline (name only), there will be
no methods or dependent types populated.
It is this latter aspect that must be done - BUT only if the parameterized type is newly defined.
-
Constructor Summary
ConstructorDescriptionResolvedOrDefineResult
(Optional<PossibleGenericSymbol> symbol, boolean newlyDefined) Creates an instance of aResolvedOrDefineResult
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.boolean
Returns the value of thenewlyDefined
record component.symbol()
Returns the value of thesymbol
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
ResolvedOrDefineResult
Creates an instance of aResolvedOrDefineResult
record class.- Parameters:
symbol
- the value for thesymbol
record componentnewlyDefined
- the value for thenewlyDefined
record component
-
-
Method Details
-
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 '=='. -
symbol
Returns the value of thesymbol
record component.- Returns:
- the value of the
symbol
record component
-
newlyDefined
public boolean newlyDefined()Returns the value of thenewlyDefined
record component.- Returns:
- the value of the
newlyDefined
record component
-