Class CtPackageImpl
java.lang.Object
spoon.support.reflect.declaration.CtElementImpl
spoon.support.reflect.declaration.CtNamedElementImpl
spoon.support.reflect.declaration.CtPackageImpl
- All Implemented Interfaces:
Serializable,Cloneable,FactoryAccessor,SourcePositionHolder,CtElement,CtNamedElement,CtPackage,CtShadowable,CtQueryable,CtVisitable
- Direct Known Subclasses:
CtModelImpl.CtRootPackage
The implementation for
CtPackage.- Author:
- Renaud Pawlak
- See Also:
- Serialized Form
-
Field Summary
FieldsFields inherited from class spoon.support.reflect.declaration.CtElementImpl
ERROR_MESSAGE_TO_STRING, factory, LOGGER, parentFields inherited from interface spoon.reflect.declaration.CtPackage
PACKAGE_SEPARATOR, PACKAGE_SEPARATOR_CHAR, TOP_LEVEL_PACKAGE_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAccepts a visitor<T extends CtPackage>
TaddPackage(CtPackage pack)add a subpackage<T extends CtPackage>
TAdds a type to this package.clone()Clone the element which calls this method in a new object.Gets the declaring module.Gets the declaring package of the current one.getPackage(String simpleName)Searches a child package by name.Gets the set of included child packages.Returns the fully qualified name of this package.Returns the corresponding reference.<T extends CtType<?>>
TFinds a top-level type by name.getTypes()Returns the set of the top-level types in this package.booleanbooleanReturns true if this package contains any sub-packages.booleanhasTypes()Returns true if this package contains any types.booleanisEmpty()booleanisShadow()When an element isn't present in the factory (created in another factory), this element is considered as "shadow".booleanReturnstrueif this is an unnamed Java package.booleanremovePackage(CtPackage pack)remove a subpackagevoidremoveType(CtType<?> type)Removes a type from this package.<T extends CtPackage>
TsetPackages(Set<CtPackage> packs)Sets the children defined in this package<E extends CtShadowable>
EsetShadow(boolean isShadow)Marks an element as shadow.<T extends CtNamedElement>
TsetSimpleName(String simpleName)Sets the simple (unqualified) name of this element.<T extends CtPackage>
TSets the types defined in the package.toString()Methods inherited from class spoon.support.reflect.declaration.CtNamedElementImpl
getSimpleNameMethods inherited from class spoon.support.reflect.declaration.CtElementImpl
addAnnotation, addComment, asIterable, comment, delete, descendantIterator, emptyList, emptySet, equals, filterChildren, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getFactory, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hashCode, hasParent, isImplicit, isParentInitialized, map, map, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setFactory, setImplicit, setParent, setPosition, setPositions, setValueByRole, toStringDebug, unmodifiableList, updateAllParentsBelowMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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, toStringDebug, updateAllParentsBelowMethods inherited from interface spoon.reflect.declaration.CtNamedElement
getSimpleNameMethods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, mapMethods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Field Details
-
packs
-
-
Constructor Details
-
CtPackageImpl
public CtPackageImpl()
-
-
Method Details
-
accept
Description copied from interface:CtVisitableAccepts a visitor- Specified by:
acceptin interfaceCtVisitable
-
addPackage
Description copied from interface:CtPackageadd a subpackage- Specified by:
addPackagein interfaceCtPackage- Returns:
- true if this element changed as a result of the call
-
removePackage
Description copied from interface:CtPackageremove a subpackage- Specified by:
removePackagein interfaceCtPackage- Returns:
- true if this element changed as a result of the call
-
getDeclaringModule
Description copied from interface:CtPackageGets the declaring module.- Specified by:
getDeclaringModulein interfaceCtPackage
-
getDeclaringPackage
Description copied from interface:CtPackageGets the declaring package of the current one. Returns null if the package is not yet in another one.- Specified by:
getDeclaringPackagein interfaceCtPackage
-
getPackage
Description copied from interface:CtPackageSearches a child package by name.- Specified by:
getPackagein interfaceCtPackage- Parameters:
simpleName- the simple name of searched package- Returns:
- the found package or null
-
getPackages
Description copied from interface:CtPackageGets the set of included child packages. This method might take linear time (regarding the amount of packages in this package). For emptiness-checks,CtPackage.hasPackages()should be preferred.- Specified by:
getPackagesin interfaceCtPackage
-
setSimpleName
Description copied from interface:CtNamedElementSets the simple (unqualified) name of this element.- Specified by:
setSimpleNamein interfaceCtNamedElement- Overrides:
setSimpleNamein classCtNamedElementImpl
-
getQualifiedName
Description copied from interface:CtPackageReturns the fully qualified name of this package. This is also known as the package's canonical name.- Specified by:
getQualifiedNamein interfaceCtPackage- Returns:
- the fully qualified name of this package, or the empty string if this is the unnamed package
-
getType
Description copied from interface:CtPackageFinds a top-level type by name. -
getTypes
Description copied from interface:CtPackageReturns the set of the top-level types in this package. This method might take linear time (regarding the amount of types in this package). For emptiness-checks,CtPackage.hasTypes()should be preferred. -
setPackages
Description copied from interface:CtPackageSets the children defined in this package- Specified by:
setPackagesin interfaceCtPackage- Parameters:
packs- new set of child packages
-
setTypes
Description copied from interface:CtPackageSets the types defined in the package. -
getReference
Description copied from interface:CtNamedElementReturns the corresponding reference.- Specified by:
getReferencein interfaceCtNamedElement- Specified by:
getReferencein interfaceCtPackage- Overrides:
getReferencein classCtNamedElementImpl
-
addType
Description copied from interface:CtPackageAdds a type to this package. -
removeType
Description copied from interface:CtPackageRemoves a type from this package.- Specified by:
removeTypein interfaceCtPackage
-
toString
- Specified by:
toStringin interfaceCtElement- Overrides:
toStringin classCtElementImpl- Returns:
- the source code of this element according to the setting of
Environment.getPrettyPrintingMode().
-
isShadow
public boolean isShadow()Description copied from interface:CtShadowableWhen an element isn't present in the factory (created in another factory), this element is considered as "shadow". e.g., a shadow element can be a CtType of java.lang.Class built when we callCtTypeReference.getTypeDeclaration()on a reference of java.lang.Class.- Specified by:
isShadowin interfaceCtShadowable- Returns:
- true if the element is a shadow element, otherwise false.
-
setShadow
Description copied from interface:CtShadowableMarks an element as shadow. To know what is a shadow element, see the javadoc ofCtShadowable.isShadow().- Specified by:
setShadowin interfaceCtShadowable
-
clone
Description copied from interface:CtElementClone 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:
clonein interfaceCtElement- Specified by:
clonein interfaceCtNamedElement- Specified by:
clonein interfaceCtPackage- Overrides:
clonein classCtNamedElementImpl
-
isUnnamedPackage
public boolean isUnnamedPackage()Description copied from interface:CtPackageReturnstrueif this is an unnamed Java package. See JLS ยง7.4.2. Unnamed Packages.- Specified by:
isUnnamedPackagein interfaceCtPackage
-
hasPackageInfo
public boolean hasPackageInfo()- Specified by:
hasPackageInfoin interfaceCtPackage- Returns:
- true if the package contains a package-info.java file
-
isEmpty
public boolean isEmpty() -
hasTypes
public boolean hasTypes()Description copied from interface:CtPackageReturns true if this package contains any types. This method is expected to provide constant-time performance and should be preferred overCtPackage.getTypes().isEmpty().- Specified by:
hasTypesin interfaceCtPackage- Returns:
- true if the package contains any types.
- See Also:
CtPackage.getTypes()
-
hasPackages
public boolean hasPackages()Description copied from interface:CtPackageReturns true if this package contains any sub-packages. This method is expected to provide constant-time performance and should be preferred overCtPackage.getPackages().isEmpty().- Specified by:
hasPackagesin interfaceCtPackage- Returns:
- true if the package contains any sub-packages
- See Also:
CtPackage.getPackages()
-