Class GeneratorScope<Scope extends GeneratorScope<Scope>>

java.lang.Object
com.regnosys.rosetta.generator.GeneratorScope<Scope>
Direct Known Subclasses:
JavaScope

public abstract class GeneratorScope<Scope extends GeneratorScope<Scope>> extends Object
  • Constructor Details

    • GeneratorScope

      public GeneratorScope(String description)
    • GeneratorScope

      protected GeneratorScope(String description, Scope parent)
  • Method Details

    • childScope

      public abstract Scope childScope(String description)
      Create a child scope from this one. The implementation should simply call the constructor, e.g., `return new MyScope(this.implicitVarUtil, this);`.
    • isValidIdentifier

      public abstract boolean isValidIdentifier(String name)
      Determine whether `name` is a valid identifier in the target language. E.g., this method should return `false` if `name` is a keyword in the target language.
    • escapeName

      public String escapeName(String name)
    • isClosed

      public boolean isClosed()
    • getParent

      public Optional<Scope> getParent()
    • getDebugInfo

      public String getDebugInfo()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getIdentifiers

      public Set<GeneratedIdentifier> getIdentifiers()
    • getIdentifier

      public Optional<GeneratedIdentifier> getIdentifier(Object obj)
      Get the generated identifier of the given Rosetta object in the current scope, if it exists.
    • getIdentifierOrThrow

      public GeneratedIdentifier getIdentifierOrThrow(Object obj)
      Get the generated identifier of the given Rosetta object in the current scope, or throw if it does not exist.
    • overwriteIdentifier

      protected GeneratedIdentifier overwriteIdentifier(Object obj, String name)
    • createIdentifier

      public GeneratedIdentifier createIdentifier(Object obj, String name)
      Define the desired name for a Rosetta object in this scope.
      Throws:
      IllegalStateException - if this scope is closed.
      IllegalStateException - if this scope already contains an identifier for `obj`.
    • createIdentifier

      public GeneratedIdentifier createIdentifier(RosettaNamed obj)
      Create an identifier for the given named Rosetta object.
      Throws:
      IllegalStateException - if this scope is closed.
      IllegalStateException - if this scope already contains an identifier for `obj`.
    • createUniqueIdentifier

      public GeneratedIdentifier createUniqueIdentifier(String name)
      Create a new identifier with the desired name that is guaranteed not to clash with any identifiers defined before.
      Throws:
      IllegalStateException - if this scope is closed.
    • getOrCreateIdentifier

      public GeneratedIdentifier getOrCreateIdentifier(Object obj, String name)
      Get the generated identifier of the given Rosetta object in the current scope, or create a new one with the given desired name if it doesn't exist.
    • getOrCreateIdentifier

      public GeneratedIdentifier getOrCreateIdentifier(RosettaNamed obj)
      Get the generated identifier of the given Rosetta object in the current scope, or create a new one if it doesn't exist.
    • createKeySynonym

      public void createKeySynonym(Object key, Object keyWithIdentifier)
      Create an synonym between an object and an already existing identifiable object.
      Throws:
      IllegalStateException - if this scope is closed.
      IllegalStateException - if this scope already contains an identifier for `key`.
      IllegalStateException - if this scope does not contain an identifier for `keyWithIdentifier`.
    • createSynonym

      public void createSynonym(Object key, GeneratedIdentifier identifier)
      Create another key for a given identifier.
      Throws:
      IllegalStateException - if this scope is closed.
      IllegalStateException - if this scope already contains an identifier for `key`.
    • close

      public void close()
      Mark this scope as closed. New identifiers cannot be added to a closed scope.
      Throws:
      IllegalStateException - if this scope is closed.
    • getActualName

      public Optional<String> getActualName(GeneratedIdentifier identifier)
      Get the actual name of the given identifier. Also closes the scope and its parent scopes if they weren't closed yet.
    • getTakenNames

      protected Set<String> getTakenNames()