Class ClassUnit

    • Constructor Detail

      • ClassUnit

        public ClassUnit​(CodeLocation location,
                         Program program,
                         java.lang.String name,
                         boolean sealed)
        Builds a compilation unit, defined at the given program point.
        Parameters:
        location - the location where the unit is define within the source file
        program - the program where this unit is defined
        name - the name of the unit
        sealed - whether or not this unit is sealed, meaning that it cannot be used as super unit of other compilation units
    • Method Detail

      • getSuperclasses

        public java.util.List<ClassUnit> getSuperclasses()
        Yields the list of ClassUnits that this class inherits from.
        Returns:
        the superclasses
      • getInterfaces

        public java.util.List<InterfaceUnit> getInterfaces()
        Yields the list of InterfaceUnits implemented by this class.
        Returns:
        the interfaces
      • addSuperclass

        public final boolean addSuperclass​(ClassUnit unit)
        Adds a new ClassUnit as superclass of this unit.
        Parameters:
        unit - the unit to add
        Returns:
        true if the collection of superclasses changed as a result of the call
      • addInterface

        public final boolean addInterface​(InterfaceUnit unit)
        Adds a new InterfaceUnit as interface of this unit.
        Parameters:
        unit - the unit to add
        Returns:
        true if the collection of interfaces changed as a result of the call
      • canBeInstantiated

        public boolean canBeInstantiated()
        Description copied from class: Unit
        Yields true if this unit can be instantiated, false otherwise (e.g., interfaces, abstract classes).
        Specified by:
        canBeInstantiated in class Unit
        Returns:
        true if this unit can be instantiated, false otherwise
      • addAncestor

        public boolean addAncestor​(CompilationUnit unit)
        Description copied from class: CompilationUnit
        Adds a new CompilationUnit as direct inheritance ancestor (i.e., superclass, interface, or superinterface) of this unit.
        Specified by:
        addAncestor in class CompilationUnit
        Parameters:
        unit - the unit to add
        Returns:
        true if the collection of ancestors changed as a result of the call