Class CompilationUnitExtension


  • public class CompilationUnitExtension
    extends Object
    • Constructor Detail

      • CompilationUnitExtension

        public CompilationUnitExtension()
    • Method Detail

      • getContainedClass

        public static Class getContainedClass​(CompilationUnit me)
        Returns the class that is directly contained in the compilation unit (if exactly one exists). If the CompilationUnit contains multiple classifiers or if the contained classifier is not a Class, null is returned.
        Returns:
        the class directly contained in the compilation unit (if there is exactly one contained classifier that is of type Class)
      • getContainedInterface

        public static Interface getContainedInterface​(CompilationUnit me)
        Returns the interface that is directly contained in the compilation unit (if exactly one exists). If the CompilationUnit contains multiple classifiers or if the contained classifier is not an Interface, null is returned.
        Returns:
        the interface directly contained in the compilation unit (if there is exactly one contained classifier that is of type Interface)
      • getContainedAnnotation

        public static Annotation getContainedAnnotation​(CompilationUnit me)
        Returns the annotation that is directly contained in the compilation unit (if exactly one exists). If the CompilationUnit contains multiple classifiers or if the contained classifier is not an Annotation, null is returned.
        Returns:
        the annotation directly contained in the compilation unit (if there is exactly one contained classifier that is of type Annotation)
      • getContainedEnumeration

        public static Enumeration getContainedEnumeration​(CompilationUnit me)
        Returns the enumeration that is directly contained in the compilation unit (if exactly one exists). If the CompilationUnit contains multiple classifiers or if the contained classifier is not an Enumeration, null is returned.
        Returns:
        the enumeration directly contained in the compilation unit (if there is exactly one contained classifier that is of type Enumeration)
      • addImport

        public static void addImport​(CompilationUnit me,
                                     String nameOfClassToImport)
        Adds an import of the given class to this compilation unit.
      • addPackageImport

        public static void addPackageImport​(CompilationUnit me,
                                            String packageName)
        Adds an import of the given package to this compilation unit.