public final class JPackage extends Object implements JDeclaration, JGenerable, JClassContainer, JAnnotatable, Comparable<JPackage>, JDocCommentable
| Modifier and Type | Method and Description | 
|---|---|
| JDefinedClass | _annotationTypeDeclaration(String name)Add an annotationType Declaration to this package | 
| JDefinedClass | _class(int mods,
      String name)Add a class to this package. | 
| JDefinedClass | _class(int mods,
      String name,
      boolean isInterface)Deprecated.   | 
| JDefinedClass | _class(int mods,
      String name,
      ClassType classTypeVal)Creates a new class/enum/interface/annotation. | 
| JDefinedClass | _class(String name)Adds a public class to this package. | 
| JDefinedClass | _enum(String name)Add a public enum to this package | 
| JDefinedClass | _getClass(String name)Gets a reference to the already created  JDefinedClass. | 
| JDefinedClass | _interface(int mods,
          String name)Add an interface to this package. | 
| JDefinedClass | _interface(String name)Adds a public interface to this package. | 
| JResourceFile | addResourceFile(JResourceFile rsrc)Adds a new resource file to this package. | 
| JAnnotationUse | annotate(Class<? extends Annotation> clazz)Adds an annotation to this program element. | 
| JAnnotationUse | annotate(JClass clazz)Adds an annotation to this program element. | 
| <W extends JAnnotationWriter> | annotate2(Class<W> clazz)Adds an annotation to this program element
 and returns a type-safe writer to fill in the values of such annotations. | 
| Collection<JAnnotationUse> | annotations()Read-only live view of all annotations on this  JAnnotatable | 
| Iterator<JDefinedClass> | classes()Returns an iterator that walks the top-level classes defined in this
 package. | 
| int | compareTo(JPackage that)Order is based on the lexicological order of the package name. | 
| void | declare(JFormatter f) | 
| void | generate(JFormatter f) | 
| JPackage | getPackage()Gets the nearest package parent. | 
| boolean | hasClasses()Checks if this package contains any classes. | 
| boolean | hasResourceFile(String name)Checks if a resource of the given name exists. | 
| boolean | isClass()Returns true if the container is a class. | 
| boolean | isDefined(String classLocalName)Checks if a given name is already defined as a class/interface | 
| boolean | isPackage()Returns true if the container is a package. | 
| boolean | isUnnamed()Checks if this package is the root, unnamed package. | 
| JDocComment | javadoc()Creates, if necessary, and returns the package javadoc for this
 JDefinedClass. | 
| String | name()Get the name of this package | 
| JCodeModel | owner()Return the code model root object being used to create this package. | 
| JPackage | parent()Gets the parent package, or null if this class is the root package. | 
| JClassContainer | parentContainer()Parent JClassContainer. | 
| Iterator<JResourceFile> | propertyFiles()Iterates all resource files in this package. | 
| JClass | ref(String name)Reference a class within this package. | 
| void | remove(JClass c)Removes a class from this package. | 
| boolean | removeAnnotation(JAnnotationUse annotation)Removes annotation from this program element. | 
| JPackage | subPackage(String pkg)Gets a reference to a sub package of this package. | 
public JClassContainer parentContainer()
JClassContainerparentContainer in interface JClassContainerpublic JPackage parent()
public boolean isClass()
JClassContainerisClass in interface JClassContainerpublic boolean isPackage()
JClassContainerisPackage in interface JClassContainerpublic JPackage getPackage()
JClassContainer
 If this.isPackage(), then return this.
getPackage in interface JClassContainerpublic JDefinedClass _class(int mods, String name) throws JClassAlreadyExistsException
_class in interface JClassContainermods - Modifiers for this class declarationname - Name of class to be added to this packageJClassAlreadyExistsException - When the specified class/interface was already created.public JDefinedClass _class(int mods, String name, boolean isInterface) throws JClassAlreadyExistsException
_class in interface JClassContainerJClassAlreadyExistsExceptionpublic JDefinedClass _class(int mods, String name, ClassType classTypeVal) throws JClassAlreadyExistsException
JClassContainer_class in interface JClassContainerJClassAlreadyExistsExceptionpublic JDefinedClass _class(String name) throws JClassAlreadyExistsException
_class in interface JClassContainerJClassAlreadyExistsException - When the specified class/interface was already created.public JDefinedClass _getClass(String name)
JDefinedClass.public int compareTo(JPackage that)
compareTo in interface Comparable<JPackage>public JDefinedClass _interface(int mods, String name) throws JClassAlreadyExistsException
_interface in interface JClassContainermods - Modifiers for this interface declarationname - Name of interface to be added to this packageJClassAlreadyExistsException - When the specified class/interface was already created.public JDefinedClass _interface(String name) throws JClassAlreadyExistsException
_interface in interface JClassContainerJClassAlreadyExistsException - When the specified class/interface was already created.public JDefinedClass _annotationTypeDeclaration(String name) throws JClassAlreadyExistsException
_annotationTypeDeclaration in interface JClassContainername - Name of the annotation Type declaration to be added to this packageJClassAlreadyExistsException - When the specified class/interface was already created.public JDefinedClass _enum(String name) throws JClassAlreadyExistsException
_enum in interface JClassContainername - Name of the enum to be added to this packageJClassAlreadyExistsException - When the specified class/interface was already created.public JResourceFile addResourceFile(JResourceFile rsrc)
public boolean hasResourceFile(String name)
public Iterator<JResourceFile> propertyFiles()
public JDocComment javadoc()
javadoc in interface JDocCommentablepublic void remove(JClass c)
public JClass ref(String name) throws ClassNotFoundException
ClassNotFoundExceptionpublic JPackage subPackage(String pkg)
public Iterator<JDefinedClass> classes()
classes in interface JClassContainerpublic boolean hasClasses()
true if this package contains any classes
         or false otherwise.public boolean isDefined(String classLocalName)
public final boolean isUnnamed()
public String name()
"java.lang"public final JCodeModel owner()
owner in interface JClassContainerpublic JAnnotationUse annotate(JClass clazz)
JAnnotatableannotate in interface JAnnotatableclazz - The annotation class to annotate the program element withpublic JAnnotationUse annotate(Class<? extends Annotation> clazz)
JAnnotatableannotate in interface JAnnotatableclazz - The annotation class to annotate the program element withpublic <W extends JAnnotationWriter> W annotate2(Class<W> clazz)
JAnnotatableannotate2 in interface JAnnotatablepublic boolean removeAnnotation(JAnnotationUse annotation)
JAnnotatableremoveAnnotation in interface JAnnotatableannotation - The annotation to be removed from the program elementpublic Collection<JAnnotationUse> annotations()
JAnnotatableJAnnotatableannotations in interface JAnnotatablepublic void declare(JFormatter f)
declare in interface JDeclarationpublic void generate(JFormatter f)
generate in interface JGenerableCopyright © 2019 JBoss by Red Hat. All rights reserved.