Class ComponentTypeSymbol

java.lang.Object
de.monticore.symbols.compsymbols._symboltable.ComponentTypeSymbolTOP
de.monticore.symbols.compsymbols._symboltable.ComponentTypeSymbol
All Implemented Interfaces:
ICommonCompSymbolsSymbol, de.monticore.symboltable.IScopeSpanningSymbol, de.monticore.symboltable.ISymbol
Direct Known Subclasses:
ComponentTypeSymbolSurrogateTOP

public class ComponentTypeSymbol extends ComponentTypeSymbolTOP
  • Constructor Details

    • ComponentTypeSymbol

      public ComponentTypeSymbol(String name)
  • Method Details

    • getParameter

      public Optional<VariableSymbol> getParameter(@NonNull String name)
    • addParameter

      public boolean addParameter(@NonNull VariableSymbol parameter)
      Overrides:
      addParameter in class ComponentTypeSymbolTOP
    • hasParameters

      public boolean hasParameters()
    • hasTypeParameter

      public boolean hasTypeParameter()
    • getPort

      public Optional<PortSymbol> getPort(@NonNull String name)
      Returns the port of this component that matches the given name, if it exists. Does not consider inherited ports.
      Parameters:
      name - the name of the port
      Returns:
      the port with the given name wrapped in an Optional or an empty Optional if no such port exists
    • getPort

      public Optional<PortSymbol> getPort(@NonNull String name, boolean searchSuper)
      Returns the port of this component that matches the given name, if it exists. Does consider inherited ports if searchSuper is set to true.
      Parameters:
      name - the name of the port
      searchSuper - whether to consider ports of super components
      Returns:
      the port with the given name wrapped in an Optional or an empty Optional if no such port exists.
    • getIncomingPorts

      public List<PortSymbol> getIncomingPorts()
      Returns the incoming ports of this component. Does not include inherited ports.
      Returns:
      a List of incoming ports of this component
    • getIncomingPort

      public Optional<PortSymbol> getIncomingPort(@NonNull String name)
      Returns the incoming port of this component that matches the given name, if it exists. Does not consider inherited ports.
      Parameters:
      name - the name of the port
      Returns:
      the incoming port with the given name wrapped in an Optional or an empty Optional if no such port exists.
    • getIncomingPort

      public Optional<PortSymbol> getIncomingPort(@NonNull String name, boolean searchSuper)
      Returns the incoming port with matching name of this component, if it exists. Does consider inherited ports if searchSuper is set to true.
      Parameters:
      name - the name of the port
      searchSuper - whether to consider ports of super components
      Returns:
      the incoming port with the given name wrapped in an Optional or an empty Optional if no such port exists
    • getOutgoingPorts

      public List<PortSymbol> getOutgoingPorts()
      Returns the outgoing ports of this component. Does not include inherited ports.
      Returns:
      a List of the outgoing ports of this component
    • getOutgoingPort

      public Optional<PortSymbol> getOutgoingPort(@NonNull String name)
      Returns the outgoing port of this component that matches the given name, if it exists. Does not consider inherited ports.
      Parameters:
      name - the name of the port
      Returns:
      the outgoing port with the given name wrapped in an Optional or an empty Optional if no such port exists.
    • getOutgoingPort

      public Optional<PortSymbol> getOutgoingPort(@NonNull String name, boolean searchSuper)
      Returns the outgoing port of this component that matches the given name, if it exists. Does consider inherited ports if searchSuper is set to true.
      Parameters:
      name - the name of the port
      searchSuper - whether to consider ports of super components
      Returns:
      the outgoing port with the given name wrapped in an Optional or an empty Optional if no such port exists
    • getPorts

      public List<PortSymbol> getPorts(boolean incoming, boolean outgoing)
      Returns the ports of this component with matching direction. Does not included inherited ports.
      Parameters:
      incoming - whether to included incoming ports
      outgoing - whether to included outgoing ports
      Returns:
      a List of all ports of this component the given direction
    • getAllPorts

      public Set<PortSymbol> getAllPorts()
      Return all ports of this component, including inherited ports.
      Returns:
      a Set of all ports of this component
    • getAllPorts

      protected Set<PortSymbol> getAllPorts(Collection<ComponentTypeSymbol> visited)
    • getAllIncomingPorts

      public Set<PortSymbol> getAllIncomingPorts()
      Returns all incoming ports of this component, including inherited ports.
      Returns:
      a Set of all incoming ports of this component
    • getAllOutgoingPorts

      public Set<PortSymbol> getAllOutgoingPorts()
      Returns all outgoing ports of this component, including inherited ports.
      Returns:
      a Set of all outgoing ports of this component
    • getAllPorts

      public Set<PortSymbol> getAllPorts(boolean incoming, boolean outgoing)
      Returns the ports of this component with matching direction. Does included inherited ports.
      Parameters:
      incoming - whether to included incoming ports
      outgoing - whether to included outgoing ports
      Returns:
      a Set of all ports of this component with the given direction
    • hasPorts

      public boolean hasPorts()
    • getSubcomponents

      public Optional<SubcomponentSymbol> getSubcomponents(@NonNull String name)
      Returns the subcomponent with matching name of this component, if it exists.
      Parameters:
      name - the name of the subcomponent
      Returns:
      the subcomponent with the given name wrapped in an Optional or an empty Optional if no such subcomponent exists.
    • isDecomposed

      public boolean isDecomposed()
    • isAtomic

      public boolean isAtomic()
    • getRefinementStart

      public Optional<ComponentTypeSymbol> getRefinementStart()
      Helper function that transitively determines the start of the refinement chain.

      Example: A refines B, C; B refines D; C refines D; The unique start is D.

      A component without explicit refinements is itself the start on the chain. If there does not exist an unique start (A refines B, C and B, C are unrefined) we throw an error.

    • getFields

      public List<VariableSymbol> getFields()
      Returns:
      a List of the fields of this component type.
    • getField

      public Optional<VariableSymbol> getField(@NonNull String name)
      Searches the fields of this component type for a field with the given name. Returns an Optional of a field of this component type with the given name, or an empty Optional if no such field exists. Throws an IllegalArgumentException if the given name is null.
      Parameters:
      name - the name of the field.
      Returns:
      an Optional of a field of this component type with the given name, or an empty Optional if no such field exists.