Class CompilationUnitExtension
java.lang.Object
tools.mdsd.jamopp.model.java.extensions.containers.CompilationUnitExtension
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddImport(CompilationUnit compilationUnit, String nameOfClassToImport) Adds an import of the given class to this compilation unit.static voidaddPackageImport(CompilationUnit compilationUnit, String packageName) Adds an import of the given package to this compilation unit.static EList<ConcreteClassifier>getClassifiersInSamePackage(CompilationUnit compilationUnit) static AnnotationgetContainedAnnotation(CompilationUnit compilationUnit) Returns the annotation that is directly contained in the compilation unit (if exactly one exists).static ClassgetContainedClass(CompilationUnit compilationUnit) Returns the class that is directly contained in the compilation unit (if exactly one exists).static ConcreteClassifiergetContainedClassifier(CompilationUnit compilationUnit, String name) Returns the firstConcreteClassifierthat is contained in thisCompilationUnitand which has the given name.static EnumerationgetContainedEnumeration(CompilationUnit compilationUnit) Returns the enumeration that is directly contained in the compilation unit (if exactly one exists).static InterfacegetContainedInterface(CompilationUnit compilationUnit) Returns the interface that is directly contained in the compilation unit (if exactly one exists).
-
Method Details
-
getContainedClassifier
public static ConcreteClassifier getContainedClassifier(CompilationUnit compilationUnit, String name) Returns the firstConcreteClassifierthat is contained in thisCompilationUnitand which has the given name.- Parameters:
name- the name of the classifier to search for- Returns:
- the classifier if one is found, otherwise
null
-
getClassifiersInSamePackage
public static EList<ConcreteClassifier> getClassifiersInSamePackage(CompilationUnit compilationUnit) - Returns:
- all classes in the same package imports
-
getContainedClass
Returns the class that is directly contained in the compilation unit (if exactly one exists). If theCompilationUnitcontains multiple classifiers or if the contained classifier is not aClass,nullis returned.- Returns:
- the class directly contained in the compilation unit (if there is
exactly one contained classifier that is of type
Class)
-
getContainedInterface
Returns the interface that is directly contained in the compilation unit (if exactly one exists). If theCompilationUnitcontains multiple classifiers or if the contained classifier is not anInterface,nullis returned.- Returns:
- the interface directly contained in the compilation unit (if there is
exactly one contained classifier that is of type
Interface)
-
getContainedAnnotation
Returns the annotation that is directly contained in the compilation unit (if exactly one exists). If theCompilationUnitcontains multiple classifiers or if the contained classifier is not anAnnotation,nullis returned.- Returns:
- the annotation directly contained in the compilation unit (if there
is exactly one contained classifier that is of type
Annotation)
-
getContainedEnumeration
Returns the enumeration that is directly contained in the compilation unit (if exactly one exists). If theCompilationUnitcontains multiple classifiers or if the contained classifier is not anEnumeration,nullis returned.- Returns:
- the enumeration directly contained in the compilation unit (if there
is exactly one contained classifier that is of type
Enumeration)
-
addImport
Adds an import of the given class to this compilation unit. -
addPackageImport
Adds an import of the given package to this compilation unit.
-