Module aya.base

Record Class ModuleSymbol<T>

java.lang.Object
java.lang.Record
org.aya.resolve.context.ModuleSymbol<T>
Record Components:
table - `Unqualified -> (Component -> Symbol)`
It says a `Symbol` can be referred by `{Component}::{Unqualified}`

public record ModuleSymbol<T>(@NotNull kala.collection.mutable.MutableMap<String,kala.collection.mutable.MutableMap<ModuleName,T>> table) extends Record
A container of symbols.
API Note:
the methods that end with `Definitely` will get/remove only one symbol or fail if ambiguous.
  • Constructor Details

    • ModuleSymbol

      public ModuleSymbol()
    • ModuleSymbol

      public ModuleSymbol(@NotNull @NotNull ModuleSymbol<T> other)
    • ModuleSymbol

      public ModuleSymbol(@NotNull @NotNull kala.collection.mutable.MutableMap<String,kala.collection.mutable.MutableMap<ModuleName,T>> table)
      Creates an instance of a ModuleSymbol record class.
      Parameters:
      table - the value for the table record component
  • Method Details

    • resolveUnqualified

      @NotNull public @NotNull ModuleSymbol.UnqualifiedResolve<T> resolveUnqualified(@NotNull @NotNull String unqualifiedName)
      Getting the candidates of an unqualified name
      Parameters:
      unqualifiedName - the unqualified name
    • getQualifiedMaybe

      @NotNull public @NotNull kala.control.Option<T> getQualifiedMaybe(@NotNull @NotNull ModuleName component, @NotNull @NotNull String unqualifiedName)
      Getting a symbol of an unqualified name in component
      Parameters:
      component - the component
      unqualifiedName - the unqualified name
      Returns:
      none if not found
    • getUnqualifiedMaybe

      @NotNull public @NotNull kala.control.Result<T,ModuleSymbol.Error> getUnqualifiedMaybe(@NotNull @NotNull String unqualifiedName)
      Trying to get a symbol of an unqualified name definitely.
      Parameters:
      unqualifiedName - the unqualified name
    • getMaybe

      @NotNull public @NotNull kala.control.Result<T,ModuleSymbol.Error> getMaybe(@NotNull @NotNull ModuleName component, @NotNull @NotNull String unqualifiedName)
      Trying to get a symbol of an optional component and an unqualified name.
      Parameters:
      component - an optional component, none if `This`
      unqualifiedName - the unqualified name
    • contains

      public boolean contains(@NotNull @NotNull String unqualified)
    • contains

      public boolean contains(@NotNull @NotNull ModuleName component, @NotNull @NotNull String unqualified)
    • add

      public kala.control.Option<T> add(@NotNull @NotNull ModuleName componentName, @NotNull @NotNull String name, @NotNull T ref)
      Adding a new symbol which can be referred by `{componentName}::{name}`
      Implementation Note:
      This method always overwrites the symbol that is added in the past.
    • remove

      public kala.control.Option<T> remove(@NotNull @NotNull ModuleName component, @NotNull @NotNull String unqualifiedName)
    • removeDefinitely

      public kala.control.Result<T,ModuleSymbol.Error> removeDefinitely(@NotNull @NotNull String unqualifiedName)
    • removeDefinitely

      public kala.control.Result<T,ModuleSymbol.Error> removeDefinitely(@NotNull @NotNull ModuleName component, @NotNull @NotNull String unqualifiedName)
    • keysView

      @NotNull public @NotNull kala.collection.SetView<String> keysView()
    • view

      @NotNull public @NotNull kala.collection.MapView<String,kala.collection.Map<ModuleName,T>> view()
    • forEach

      public void forEach(@NotNull @NotNull BiConsumer<String,kala.collection.Map<ModuleName,T>> action)
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • table

      @NotNull public @NotNull kala.collection.mutable.MutableMap<String,kala.collection.mutable.MutableMap<ModuleName,T>> table()
      Returns the value of the table record component.
      Returns:
      the value of the table record component