Class Modules<T extends Module>

java.lang.Object
org.ek9lang.compiler.Modules<T>
All Implemented Interfaces:
Serializable

public class Modules<T extends Module> extends Object implements Serializable
With EK9 it is possible to have multiple source files that are all in the same 'module'. This object represents that concept. So the module name is always the same but there can and will be multiple modules.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Modules(String moduleName)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T module)
    Add a module to the set all under the same moduleName.
    Provides an immutable snapshot of the parsed modules.
    void
    remove(T module)
    Remove an existing module for the set of modules recorded against a specific module name.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Modules

      public Modules(String moduleName)
  • Method Details

    • add

      public void add(T module)
      Add a module to the set all under the same moduleName.
    • remove

      public void remove(T module)
      Remove an existing module for the set of modules recorded against a specific module name.
    • getModules

      public List<T> getModules()
      Provides an immutable snapshot of the parsed modules.

      Returns List.copyOf(Collection) rather than Collections.unmodifiableList(List) because callers obtain this list while inside a SharedThreadContext.accept(...) lock but may iterate it after the lock is released. An unmodifiable view shares the backing array with this object's modulesInModule, so a concurrent add(T) (legitimately running under the lock in another scheduled accept call) can mutate the backing array and surface as a ConcurrentModificationException in the earlier caller's iteration. A snapshot taken at the call site is consistent and insulates the caller from later mutations.