org.mule.devkit.model.code
Class GeneratedPackage

java.lang.Object
  extended by org.mule.devkit.model.code.GeneratedPackage
All Implemented Interfaces:
Comparable<GeneratedPackage>, Annotable, ClassContainer, Declaration, Documentable, Generable

public final class GeneratedPackage
extends Object
implements Declaration, Generable, ClassContainer, Annotable, Comparable<GeneratedPackage>, Documentable

A Java package.


Method Summary
 GeneratedClass _annotationTypeDeclaration(String name)
          Add an annotationType Declaration to this package
 GeneratedClass _class(int mods, String name)
          Add a class to this package.
 GeneratedClass _class(int mods, String name, boolean isInterface)
          Deprecated.  
 GeneratedClass _class(int modifiers, String name, Class<?>[] _implements)
          Adds a public class to this package.
 GeneratedClass _class(int modifiers, String name, Class<?> _extends, Class<?>[] _implements)
          Adds a public class to this package.
 GeneratedClass _class(int modifiers, String name, GeneratedClass _extends, Class<?>[] _implements)
          Adds a public class to this package.
 GeneratedClass _class(int mods, String name, GeneratedClassType classTypeVal)
          Creates a new class/enum/interface/annotation.
 GeneratedClass _class(int modifiers, String name, TypeReference _extends)
          Adds a public class to this package.
 GeneratedClass _class(String name)
          Adds a public class to this package.
 GeneratedClass _class(String name, Class<?> _extends)
          Adds a public class to this package.
 GeneratedClass _class(String name, Class<?>[] _implements)
          Adds a public class to this package.
 GeneratedClass _class(String name, Class<?> _extends, Class<?>[] _implements)
          Adds a public class to this package.
 GeneratedClass _class(String name, GeneratedClass _extends, Class<?>[] _implements)
          Adds a public class to this package.
 GeneratedClass _class(String name, TypeReference _extends)
          Adds a public class to this package.
 GeneratedClass _class(String name, TypeReference _extends, Class<?>[] _implements)
          Adds a public class to this package.
 GeneratedClass _enum(String name)
          Add a public enum to this package
 GeneratedClass _getClass(String name)
          Gets a reference to the already created GeneratedClass.
 GeneratedClass _interface(int mods, String name)
          Add an interface to this package.
 GeneratedClass _interface(String name)
          Adds a public interface to this package.
 ResourceFile addResourceFile(ResourceFile rsrc)
          Adds a new resource file to this package.
 GeneratedAnnotationUse annotate(Class<? extends Annotation> clazz)
          Adds an annotation to this program element.
 GeneratedAnnotationUse annotate(TypeReference clazz)
          Adds an annotation to this program element.
<W extends AnnotationWriter>
W
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<GeneratedAnnotationUse> annotations()
          Read-only live view of all annotations on this Annotable
 Iterator<GeneratedClass> classes()
          Returns an iterator that walks the top-level classes defined in this package.
 int compareTo(GeneratedPackage that)
          Order is based on the lexicological order of the package name.
 void declare(Formatter f)
           
 void generate(Formatter f)
           
 GeneratedPackage getPackage()
          Gets the nearest package parent.
 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.
 GeneratedJavaDocComment javadoc()
          Creates, if necessary, and returns the package javadoc for this DefinedClass.
 String name()
          Get the name of this package
 CodeModel owner()
          Return the code model root object being used to create this package.
 GeneratedPackage parent()
          Gets the parent package, or null if this class is the root package.
 ClassContainer parentContainer()
          Parent ClassContainer.
 Iterator<ResourceFile> propertyFiles()
          Iterates all resource files in this package.
 TypeReference ref(String name)
          Reference a class within this package.
 void remove(TypeReference c)
          Removes a class from this package.
 GeneratedPackage subPackage(String pkg)
          Gets a reference to a sub package of this package.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parentContainer

public ClassContainer parentContainer()
Description copied from interface: ClassContainer
Parent ClassContainer.

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 package to which it belongs.

If this is an inner class, this method returns the outer class.

Specified by:
parentContainer in interface ClassContainer

parent

public GeneratedPackage parent()
Gets the parent package, or null if this class is the root package.


isClass

public boolean isClass()
Description copied from interface: ClassContainer
Returns true if the container is a class.

Specified by:
isClass in interface ClassContainer

isPackage

public boolean isPackage()
Description copied from interface: ClassContainer
Returns true if the container is a package.

Specified by:
isPackage in interface ClassContainer

getPackage

public GeneratedPackage getPackage()
Description copied from interface: ClassContainer
Gets the nearest package parent.

If this.isPackage(), then return this.

Specified by:
getPackage in interface ClassContainer

_class

public GeneratedClass _class(int mods,
                             String name)
Add a class to this package.

Specified by:
_class in interface ClassContainer
Parameters:
mods - Modifiers for this class declaration
name - Name of class to be added to this package
Returns:
Newly generated class
Throws:
ClassAlreadyExistsException - When the specified class/interface was already created.

_class

public GeneratedClass _class(int mods,
                             String name,
                             boolean isInterface)
                      throws ClassAlreadyExistsException
Deprecated. 

Create a new class or a new interface.

Specified by:
_class in interface ClassContainer
Throws:
ClassAlreadyExistsException

_class

public GeneratedClass _class(int mods,
                             String name,
                             GeneratedClassType classTypeVal)
                      throws ClassAlreadyExistsException
Description copied from interface: ClassContainer
Creates a new class/enum/interface/annotation.

Specified by:
_class in interface ClassContainer
Throws:
ClassAlreadyExistsException

_class

public GeneratedClass _class(String name)
Adds a public class to this package.

Specified by:
_class in interface ClassContainer

_class

public GeneratedClass _class(String name,
                             TypeReference _extends)
Adds a public class to this package.


_class

public GeneratedClass _class(int modifiers,
                             String name,
                             TypeReference _extends)
Adds a public class to this package.


_class

public GeneratedClass _class(String name,
                             Class<?> _extends)
Adds a public class to this package.


_class

public GeneratedClass _class(String name,
                             Class<?> _extends,
                             Class<?>[] _implements)
Adds a public class to this package.


_class

public GeneratedClass _class(int modifiers,
                             String name,
                             Class<?> _extends,
                             Class<?>[] _implements)
Adds a public class to this package.


_class

public GeneratedClass _class(String name,
                             GeneratedClass _extends,
                             Class<?>[] _implements)
Adds a public class to this package.


_class

public GeneratedClass _class(String name,
                             TypeReference _extends,
                             Class<?>[] _implements)
Adds a public class to this package.


_class

public GeneratedClass _class(int modifiers,
                             String name,
                             GeneratedClass _extends,
                             Class<?>[] _implements)
Adds a public class to this package.


_class

public GeneratedClass _class(String name,
                             Class<?>[] _implements)
Adds a public class to this package.


_class

public GeneratedClass _class(int modifiers,
                             String name,
                             Class<?>[] _implements)
Adds a public class to this package.


_getClass

public GeneratedClass _getClass(String name)
Gets a reference to the already created GeneratedClass.

Returns:
null If the class is not yet created.

compareTo

public int compareTo(GeneratedPackage that)
Order is based on the lexicological order of the package name.

Specified by:
compareTo in interface Comparable<GeneratedPackage>

_interface

public GeneratedClass _interface(int mods,
                                 String name)
Add an interface to this package.

Specified by:
_interface in interface ClassContainer
Parameters:
mods - Modifiers for this interface declaration
name - Name of interface to be added to this package
Returns:
Newly generated interface

_interface

public GeneratedClass _interface(String name)
                          throws ClassAlreadyExistsException
Adds a public interface to this package.

Specified by:
_interface in interface ClassContainer
Throws:
ClassAlreadyExistsException - When the specified class/interface was already created.

_annotationTypeDeclaration

public GeneratedClass _annotationTypeDeclaration(String name)
                                          throws ClassAlreadyExistsException
Add an annotationType Declaration to this package

Specified by:
_annotationTypeDeclaration in interface ClassContainer
Parameters:
name - Name of the annotation Type declaration to be added to this package
Returns:
newly created Annotation Type Declaration
Throws:
ClassAlreadyExistsException - When the specified class/interface was already created.

_enum

public GeneratedClass _enum(String name)
                     throws ClassAlreadyExistsException
Add a public enum to this package

Specified by:
_enum in interface ClassContainer
Parameters:
name - Name of the enum to be added to this package
Returns:
newly created Enum
Throws:
ClassAlreadyExistsException - When the specified class/interface was already created.

addResourceFile

public ResourceFile addResourceFile(ResourceFile rsrc)
Adds a new resource file to this package.


hasResourceFile

public boolean hasResourceFile(String name)
Checks if a resource of the given name exists.


propertyFiles

public Iterator<ResourceFile> propertyFiles()
Iterates all resource files in this package.


javadoc

public GeneratedJavaDocComment javadoc()
Creates, if necessary, and returns the package javadoc for this DefinedClass.

Specified by:
javadoc in interface Documentable
Returns:
JDocComment containing javadocs for this class

remove

public void remove(TypeReference c)
Removes a class from this package.


ref

public TypeReference ref(String name)
                  throws ClassNotFoundException
Reference a class within this package.

Throws:
ClassNotFoundException

subPackage

public GeneratedPackage subPackage(String pkg)
Gets a reference to a sub package of this package.


classes

public Iterator<GeneratedClass> classes()
Returns an iterator that walks the top-level classes defined in this package.

Specified by:
classes in interface ClassContainer

isDefined

public boolean isDefined(String classLocalName)
Checks if a given name is already defined as a class/interface


isUnnamed

public final boolean isUnnamed()
Checks if this package is the root, unnamed package.


name

public String name()
Get the name of this package

Returns:
The name of this package, or the empty string if this is the null package. For example, this method returns strings like "java.lang"

owner

public final CodeModel owner()
Return the code model root object being used to create this package.

Specified by:
owner in interface ClassContainer

annotate

public GeneratedAnnotationUse annotate(TypeReference clazz)
Description copied from interface: Annotable
Adds an annotation to this program element.

Specified by:
annotate in interface Annotable
Parameters:
clazz - The annotation class to annotate the program element with

annotate

public GeneratedAnnotationUse annotate(Class<? extends Annotation> clazz)
Description copied from interface: Annotable
Adds an annotation to this program element.

Specified by:
annotate in interface Annotable
Parameters:
clazz - The annotation class to annotate the program element with

annotate2

public <W extends AnnotationWriter> W annotate2(Class<W> clazz)
Description copied from interface: Annotable
Adds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.

Specified by:
annotate2 in interface Annotable

annotations

public Collection<GeneratedAnnotationUse> annotations()
Description copied from interface: Annotable
Read-only live view of all annotations on this Annotable

Specified by:
annotations in interface Annotable
Returns:
Can be empty but never null.

declare

public void declare(Formatter f)
Specified by:
declare in interface Declaration

generate

public void generate(Formatter f)
Specified by:
generate in interface Generable


Copyright © 2010–2014 MuleSoft, Inc.. All rights reserved.