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 Details

    • ResolvedOrDefineResult

      public ResolvedOrDefineResult(Optional<PossibleGenericSymbol> symbol, boolean newlyDefined)
      Creates an instance of a ResolvedOrDefineResult record class.
      Parameters:
      symbol - the value for the symbol record component
      newlyDefined - the value for the newlyDefined record component
  • Method Details

    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • symbol

      public Optional<PossibleGenericSymbol> symbol()
      Returns the value of the symbol record component.
      Returns:
      the value of the symbol record component
    • newlyDefined

      public boolean newlyDefined()
      Returns the value of the newlyDefined record component.
      Returns:
      the value of the newlyDefined record component