Class PackageFactory

java.lang.Object
spoon.reflect.factory.SubFactory
spoon.reflect.factory.PackageFactory

public class PackageFactory extends SubFactory
The CtPackage sub-factory.
  • Constructor Details

    • PackageFactory

      public PackageFactory(Factory factory)
      Creates a new package sub-factory.
      Parameters:
      factory - the parent factory
  • Method Details

    • createReference

      public CtPackageReference createReference(CtPackage pack)
      Creates a reference to an existing package. The simple name of the reference will be the FQN of the given package
    • createReference

      public CtPackageReference createReference(Package pack)
      Creates a reference to a package by using its Java runtime representation. The simple name of the reference will be the FQN of the given package
      Parameters:
      pack - a runtime package
      Returns:
      reference to the package
    • topLevel

      public CtPackageReference topLevel()
      Returns a reference on the top level package.
    • createReference

      public CtPackageReference createReference(String name)
      Creates a reference to a package. The given name has to be a fully qualified name.
      Parameters:
      name - full name of the package to reference
    • createPackageDeclaration

      public CtPackageDeclaration createPackageDeclaration(CtPackageReference packageRef)
      Creates a package declaration of a package.
      Parameters:
      packageRef - a reference to a package
    • create

      public CtPackage create(CtPackage parent, String simpleName)
      Creates a new package (see also getOrCreate(String)).
      Parameters:
      parent - the parent package (can be null)
      simpleName - the package's simple name (no dots)
      Returns:
      the newly created package
    • getOrCreate

      public CtPackage getOrCreate(String qualifiedName)
      Gets or creates a package for the unnamed module
      Parameters:
      qualifiedName - the full name of the package
    • getOrCreate

      public CtPackage getOrCreate(String qualifiedName, CtModule rootModule)
      Gets or creates a package and make its parent the given module
      Parameters:
      qualifiedName - the full name of the package
      rootModule - The parent module of the package
    • get

      public CtPackage get(String qualifiedName)
      Gets a package.
      Parameters:
      qualifiedName - the package to search
      Returns:
      a found package or null
    • getAll

      public Collection<CtPackage> getAll()
      Gets the list of all created packages. It includes all the top-level packages and their sub-packages.
    • getRootPackage

      public CtPackage getRootPackage()
      Return the unnamed top-level package.