Package spoon.reflect.declaration
Interface CtModule
- All Superinterfaces:
Cloneable
,CtElement
,CtNamedElement
,CtQueryable
,CtVisitable
,FactoryAccessor
,Serializable
,SourcePositionHolder
- All Known Implementing Classes:
CtModuleImpl
,ModuleFactory.CtUnnamedModule
Represents a Java module as defined in Java 9.
Modules are defined in `module-info.java` as follows:
module com.example.foo { }Modules define required modules, and exported packages for client code. A module can export a service, defined as a type. Provided services are implementations of given service. Modules can require services ("uses" in Java 9) An open module, with the open modifier, grants access at compile time to types in only those packages which are explicitly exported, but grants access at run time to types in all its packages, as if all packages had been exported.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescription<T extends CtModule>
TaddExportedPackage(CtPackageExport exportedPackage)
<T extends CtModule>
TaddModuleDirective(CtModuleDirective moduleDirective)
<T extends CtModule>
TaddModuleDirectiveAt(int position, CtModuleDirective moduleDirective)
<T extends CtModule>
TaddOpenedPackage(CtPackageExport openedPackage)
<T extends CtModule>
TaddProvidedService(CtProvidedService providedService)
<T extends CtModule>
TaddRequiredModule(CtModuleRequirement requiredModule)
<T extends CtModule>
TaddUsedService(CtUsedService usedService)
clone()
Clone the element which calls this method in a new object.Returns the corresponding reference.returns the root package of the unnamed module If there are several modules, it throws an exceptionboolean
boolean
Returns true if the module is the unnamed module<T extends CtModule>
TremoveExportedPackage(CtPackageExport exportedPackage)
<T extends CtModule>
TremoveModuleDirective(CtModuleDirective moduleDirective)
<T extends CtModule>
TremoveOpenedPackage(CtPackageExport openedPackage)
<T extends CtModule>
TremoveProvidedService(CtProvidedService providedService)
<T extends CtModule>
TremoveRequiredModule(CtModuleRequirement requiredModule)
<T extends CtModule>
TremoveUsedService(CtUsedService usedService)
<T extends CtModule>
TsetExportedPackages(List<CtPackageExport> exportedPackages)
<T extends CtModule>
TsetIsOpenModule(boolean openModule)
<T extends CtModule>
TsetModuleDirectives(List<CtModuleDirective> moduleDirectives)
<T extends CtModule>
TsetOpenedPackages(List<CtPackageExport> openedPackages)
<T extends CtModule>
TsetProvidedServices(List<CtProvidedService> providedServices)
<T extends CtModule>
TsetRequiredModules(List<CtModuleRequirement> requiredModules)
<T extends CtModule>
TsetRootPackage(CtPackage rootPackage)
<T extends CtModule>
TsetUsedServices(List<CtUsedService> usedServices)
Methods inherited from interface spoon.reflect.declaration.CtElement
addAnnotation, addComment, asIterable, delete, descendantIterator, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hasParent, isImplicit, isParentInitialized, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, updateAllParentsBelow
Methods inherited from interface spoon.reflect.declaration.CtNamedElement
getSimpleName, setSimpleName
Methods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, map
Methods inherited from interface spoon.reflect.visitor.CtVisitable
accept
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Field Details
-
TOP_LEVEL_MODULE_NAME
The name for the top level module.- See Also:
- Constant Field Values
-
-
Method Details
-
isUnnamedModule
boolean isUnnamedModule()Returns true if the module is the unnamed module -
isOpenModule
boolean isOpenModule() -
setIsOpenModule
-
setModuleDirectives
-
addModuleDirective
-
addModuleDirectiveAt
-
getModuleDirectives
List<CtModuleDirective> getModuleDirectives() -
removeModuleDirective
-
getUsedServices
List<CtUsedService> getUsedServices() -
setUsedServices
-
addUsedService
-
removeUsedService
-
getExportedPackages
List<CtPackageExport> getExportedPackages() -
setExportedPackages
-
addExportedPackage
-
removeExportedPackage
-
getOpenedPackages
List<CtPackageExport> getOpenedPackages() -
setOpenedPackages
-
addOpenedPackage
-
removeOpenedPackage
-
getRequiredModules
List<CtModuleRequirement> getRequiredModules() -
setRequiredModules
-
addRequiredModule
-
removeRequiredModule
-
getProvidedServices
List<CtProvidedService> getProvidedServices() -
setProvidedServices
-
addProvidedService
-
removeProvidedService
-
getRootPackage
CtPackage getRootPackage()returns the root package of the unnamed module If there are several modules, it throws an exception -
setRootPackage
-
getReference
CtModuleReference getReference()Description copied from interface:CtNamedElement
Returns the corresponding reference.- Specified by:
getReference
in interfaceCtNamedElement
-
clone
CtModule clone()Description copied from interface:CtElement
Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methodsRefactoring.copyType(CtType)
andRefactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.- Specified by:
clone
in interfaceCtElement
- Specified by:
clone
in interfaceCtNamedElement
-