public class JPackage extends Object implements IJDeclaration, IJGenerable, IJClassContainer<JDefinedClass>, IJAnnotatable, Comparable<JPackage>, IJDocCommentable
| Modifier | Constructor and Description |
|---|---|
protected |
JPackage(String sName,
JCodeModel aOwner)
JPackage constructor
|
| Modifier and Type | Method and Description |
|---|---|
JDefinedClass |
_annotationTypeDeclaration(int mods,
String name)
Add a annotationType Declaration to this package
|
JDefinedClass |
_annotationTypeDeclaration(String name)
Add a public annotationType Declaration to this package
|
JDefinedClass |
_class(int nMods,
String sName)
Add a class to this package.
|
JDefinedClass |
_class(int nMods,
String sName,
EClassType eClassType)
Creates a new class/enum/interface/annotation.
|
JDefinedClass |
_class(String sName)
Adds a public class to this package.
|
JDefinedClass |
_enum(int mods,
String name)
Add a enum to this package
|
JDefinedClass |
_enum(String name)
Add a public enum to this package
|
JDefinedClass |
_getClass(String sName)
Gets a reference to the already created
JDefinedClass. |
JDefinedClass |
_interface(int nMods,
String sName)
Add an interface to this package.
|
JDefinedClass |
_interface(String sName)
Adds a public interface to this package.
|
AbstractJResourceFile |
addResourceFile(AbstractJResourceFile rsrc)
Adds a new resource file to this package.
|
JAnnotationUse |
annotate(AbstractJClass clazz)
Adds an annotation to this program element.
|
JAnnotationUse |
annotate(Class<? extends Annotation> clazz)
Adds an annotation to this program element.
|
<W extends IJAnnotationWriter<?>> |
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
IJAnnotatable |
Collection<JDefinedClass> |
classes() |
int |
compareTo(JPackage aOther)
Order is based on the lexicographic order of the package name.
|
void |
declare(JFormatter f) |
void |
generate(JFormatter f) |
JPackage |
getPackage() |
boolean |
hasResourceFile(String name)
Checks if a resource of the given name exists.
|
boolean |
isClass() |
boolean |
isDefined(String classLocalName)
Checks if a given name is already defined as a class/interface
|
boolean |
isPackage() |
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()
Gets the owner code model object.
|
JPackage |
parent() |
IJClassContainer<?> |
parentContainer() |
Iterator<AbstractJResourceFile> |
propertyFiles()
Iterates all resource files in this package.
|
AbstractJClass |
ref(String sClassLocalName)
Reference a class within this package.
|
void |
remove(AbstractJClass c)
Removes a class from this package.
|
JPackage |
subPackage(String sSubPackageName)
Gets a reference to a sub package of this package.
|
protected JPackage(@Nonnull String sName, @Nonnull JCodeModel aOwner)
sName - Name of package. May not be null but empty.aOwner - The code writer being used to create this packageIllegalArgumentException - If each part of the package name is not a valid identifier@Nullable public IJClassContainer<?> parentContainer()
parentContainer in interface IJClassContainer<JDefinedClass>IJClassContainer. If this is a package, this method
returns a parent package, or null if this package is
the root package. If this is an outer-most class, this method
returns a JPackage to which it belongs. If this is an inner
class, this method returns the outer class.@Nullable public JPackage parent()
null if this class is the root
package.public boolean isClass()
isClass in interface IJClassContainer<JDefinedClass>true if the container is a class, false
if it is a packageIJClassContainer.isPackage()public boolean isPackage()
isPackage in interface IJClassContainer<JDefinedClass>true if the container is a package, false
if it is a class.IJClassContainer.isClass()@Nonnull public JPackage getPackage()
getPackage in interface IJClassContainer<JDefinedClass>@Nonnull public JDefinedClass _class(int nMods, @Nonnull String sName) throws JClassAlreadyExistsException
_class in interface IJClassContainer<JDefinedClass>nMods - Modifiers for this class declarationsName - Name of class to be added to this packageJClassAlreadyExistsException - When the specified class/interface was already created.@Nonnull public JDefinedClass _class(int nMods, @Nonnull String sName, @Nonnull EClassType eClassType) throws JClassAlreadyExistsException
IJClassContainer_class in interface IJClassContainer<JDefinedClass>nMods - Modifiers for this ...sName - Name of ... to be added to this package.eClassType - The type of class to create. May not be null.JClassAlreadyExistsException - If another class/interface/... with the same name already exists@Nonnull public JDefinedClass _class(@Nonnull String sName) throws JClassAlreadyExistsException
_class in interface IJClassContainer<JDefinedClass>sName - Name of class to be added to this packageJClassAlreadyExistsException - If another class/interface/... with the same name already exists@Nullable public JDefinedClass _getClass(@Nullable String sName)
JDefinedClass.sName - Class name to searchnull if the class is not yet created.public int compareTo(@Nonnull JPackage aOther)
compareTo in interface Comparable<JPackage>aOther - Other package to compare to@Nonnull public JDefinedClass _interface(int nMods, @Nonnull String sName) throws JClassAlreadyExistsException
_interface in interface IJClassContainer<JDefinedClass>nMods - Modifiers for this interface declarationsName - Name of interface to be added to this packageJClassAlreadyExistsException - If another class/interface/... with the same name already exists@Nonnull public JDefinedClass _interface(@Nonnull String sName) throws JClassAlreadyExistsException
_interface in interface IJClassContainer<JDefinedClass>sName - Name of interface to be added to this packageJClassAlreadyExistsException - If another class/interface/... with the same name already exists@Nonnull public JDefinedClass _annotationTypeDeclaration(int mods, @Nonnull String name) throws JClassAlreadyExistsException
_annotationTypeDeclaration in interface IJClassContainer<JDefinedClass>mods - Modifiers for this annotationType declarationname - Name of the annotation Type declaration to be added to this packageJClassAlreadyExistsException - When the specified class/interface was already created.@Nonnull public JDefinedClass _annotationTypeDeclaration(@Nonnull String name) throws JClassAlreadyExistsException
_annotationTypeDeclaration in interface IJClassContainer<JDefinedClass>name - Name of the annotation Type declaration to be added to this packageJClassAlreadyExistsException - When the specified class/interface was already created.@Nonnull public JDefinedClass _enum(int mods, @Nonnull String name) throws JClassAlreadyExistsException
_enum in interface IJClassContainer<JDefinedClass>mods - Modifiers for this enum declarationname - Name of the enum to be added to this packageJClassAlreadyExistsException - When the specified class/interface was already created.@Nonnull public JDefinedClass _enum(@Nonnull String name) throws JClassAlreadyExistsException
_enum in interface IJClassContainer<JDefinedClass>name - Name of the enum to be added to this packageJClassAlreadyExistsException - When the specified class/interface was already created.@Nonnull public AbstractJResourceFile addResourceFile(@Nonnull AbstractJResourceFile rsrc)
rsrc - Resource file to addpublic boolean hasResourceFile(@Nullable String name)
name - Filename to checktrue if contained@Nonnull public Iterator<AbstractJResourceFile> propertyFiles()
@Nonnull public JDocComment javadoc()
javadoc in interface IJDocCommentableJDocComment containing javadocs for this classpublic void remove(@Nonnull AbstractJClass c)
c - Class to be removed@Nonnull public AbstractJClass ref(@Nonnull String sClassLocalName) throws ClassNotFoundException
sClassLocalName - Local class name to referenceClassNotFoundException - If the provided class does not exist@Nonnull public JPackage subPackage(@Nonnull String sSubPackageName)
sSubPackageName - Name of the sub-package@Nonnull public Collection<JDefinedClass> classes()
classes in interface IJClassContainer<JDefinedClass>public boolean isDefined(@Nullable String classLocalName)
classLocalName - Class local nametrue if contained in this packagepublic final boolean isUnnamed()
true if this is the root package@Nonnull public String name()
"java.lang"@Nonnull public final JCodeModel owner()
IJOwned@Nonnull public JAnnotationUse annotate(@Nonnull AbstractJClass clazz)
IJAnnotatableannotate in interface IJAnnotatableclazz - The annotation class to annotate the program element withJAnnotationUse@Nonnull public JAnnotationUse annotate(@Nonnull Class<? extends Annotation> clazz)
IJAnnotatableannotate in interface IJAnnotatableclazz - The annotation class to annotate the program element withJAnnotationUse@Nonnull public <W extends IJAnnotationWriter<?>> W annotate2(@Nonnull Class<W> clazz)
IJAnnotatableannotate2 in interface IJAnnotatableW - Implementation typeclazz - Source class@Nonnull public Collection<JAnnotationUse> annotations()
IJAnnotatableIJAnnotatableannotations in interface IJAnnotatablenull.public void declare(@Nonnull JFormatter f)
declare in interface IJDeclarationpublic void generate(@Nonnull JFormatter f)
generate in interface IJGenerableCopyright © 2013–2015 Philip Helger. All rights reserved.