spoon.reflect.declaration.CtModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spoon-core Show documentation
Show all versions of spoon-core Show documentation
Spoon is a tool for meta-programming, analysis and transformation of Java programs.
/*
* SPDX-License-Identifier: (MIT OR CECILL-C)
*
* Copyright (C) 2006-2023 INRIA and contributors
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.reflect.declaration;
import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;
import spoon.reflect.reference.CtModuleReference;
import spoon.support.DerivedProperty;
import java.util.List;
import static spoon.reflect.path.CtRole.EXPORTED_PACKAGE;
import static spoon.reflect.path.CtRole.MODIFIER;
import static spoon.reflect.path.CtRole.MODULE_DIRECTIVE;
import static spoon.reflect.path.CtRole.OPENED_PACKAGE;
import static spoon.reflect.path.CtRole.PROVIDED_SERVICE;
import static spoon.reflect.path.CtRole.REQUIRED_MODULE;
import static spoon.reflect.path.CtRole.SERVICE_TYPE;
import static spoon.reflect.path.CtRole.SUB_PACKAGE;
/**
* 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.
*/
public interface CtModule extends CtNamedElement {
/**
* The name for the top level module.
*/
String TOP_LEVEL_MODULE_NAME = "unnamed module";
/**
* Returns true if the module is the unnamed module
*/
@DerivedProperty
boolean isUnnamedModule();
@PropertyGetter(role = MODIFIER)
boolean isOpenModule();
@PropertySetter(role = MODIFIER)
T setIsOpenModule(boolean openModule);
@PropertySetter(role = MODULE_DIRECTIVE)
T setModuleDirectives(List moduleDirectives);
@PropertySetter(role = MODULE_DIRECTIVE)
T addModuleDirective(CtModuleDirective moduleDirective);
@PropertySetter(role = MODULE_DIRECTIVE)
T addModuleDirectiveAt(int position, CtModuleDirective moduleDirective);
@PropertyGetter(role = MODULE_DIRECTIVE)
List getModuleDirectives();
@PropertySetter(role = MODULE_DIRECTIVE)
T removeModuleDirective(CtModuleDirective moduleDirective);
@PropertyGetter(role = SERVICE_TYPE)
@DerivedProperty
List getUsedServices();
@PropertySetter(role = SERVICE_TYPE)
@DerivedProperty
T setUsedServices(List usedServices);
@PropertySetter(role = SERVICE_TYPE)
@DerivedProperty
T addUsedService(CtUsedService usedService);
@PropertySetter(role = SERVICE_TYPE)
@DerivedProperty
T removeUsedService(CtUsedService usedService);
@PropertyGetter(role = EXPORTED_PACKAGE)
@DerivedProperty
List getExportedPackages();
@PropertySetter(role = EXPORTED_PACKAGE)
@DerivedProperty
T setExportedPackages(List exportedPackages);
@PropertySetter(role = EXPORTED_PACKAGE)
@DerivedProperty
T addExportedPackage(CtPackageExport exportedPackage);
@PropertySetter(role = EXPORTED_PACKAGE)
@DerivedProperty
T removeExportedPackage(CtPackageExport exportedPackage);
@PropertyGetter(role = OPENED_PACKAGE)
@DerivedProperty
List getOpenedPackages();
@PropertySetter(role = OPENED_PACKAGE)
@DerivedProperty
T setOpenedPackages(List openedPackages);
@PropertySetter(role = OPENED_PACKAGE)
@DerivedProperty
T addOpenedPackage(CtPackageExport openedPackage);
@PropertySetter(role = OPENED_PACKAGE)
@DerivedProperty
T removeOpenedPackage(CtPackageExport openedPackage);
@PropertyGetter(role = REQUIRED_MODULE)
@DerivedProperty
List getRequiredModules();
@PropertySetter(role = REQUIRED_MODULE)
@DerivedProperty
T setRequiredModules(List requiredModules);
@PropertySetter(role = REQUIRED_MODULE)
@DerivedProperty
T addRequiredModule(CtModuleRequirement requiredModule);
@PropertySetter(role = REQUIRED_MODULE)
@DerivedProperty
T removeRequiredModule(CtModuleRequirement requiredModule);
@PropertyGetter(role = PROVIDED_SERVICE)
@DerivedProperty
List getProvidedServices();
@PropertySetter(role = PROVIDED_SERVICE)
@DerivedProperty
T setProvidedServices(List providedServices);
@PropertySetter(role = PROVIDED_SERVICE)
@DerivedProperty
T addProvidedService(CtProvidedService providedService);
@PropertySetter(role = PROVIDED_SERVICE)
@DerivedProperty
T removeProvidedService(CtProvidedService providedService);
/**
* returns the root package of the unnamed module
* If there are several modules, it throws an exception
*/
@PropertyGetter(role = SUB_PACKAGE)
CtPackage getRootPackage();
@PropertySetter(role = SUB_PACKAGE)
T setRootPackage(CtPackage rootPackage);
@DerivedProperty
@Override
CtModuleReference getReference();
@Override
CtModule clone();
}