Login | Register
My pages Projects Community openCollabNet

The Tigris site will receive a major upgrade the evening of Monday, December 1, beginning at 8:30 pm PST. Downtime is projected to be about ten hours. Further details in the announcement


jmt.codebase
Class ClassFactory

java.lang.Object
  |
  +--jmt.codebase.ClassFactory

public final class ClassFactory
extends java.lang.Object

A static factory providing methods to create Class, Interface, Field, Method, ClassElements and MethodParameters instances.

Author:
Martin Kersten

Constructor Summary
ClassFactory()
           
 
Method Summary
static Class createClass(ClassName name, Modifier modifier, ClassReference superclass, ClassReference[] interfaces)
          Returns a new Class instance according to the given characteristics.
static ClassElements createClassElements()
          Returns a new instance of the ClassElements type.
static Field createField(ClassReference owner, java.lang.String name, Modifier modifier, ClassReference type)
          Returns a new Field instance representing a field of a class or an interface.
static Interface createInterface(ClassName name, Modifier modifier, ClassReference[] superclasses)
          Returns a new Interface instance according to the given characteristics.
static Method createMethod(ClassReference owner, java.lang.String name, Modifier modifier, ClassReference type, MethodParameters parameters)
          Returns a new Method instance representing a method of a class or an interface.
static MethodParameters createParameters(ClassReference[] parameters)
          Returns a MethodParameter instance describing the given parameter signature (types).
static MethodParameters getEmptyParameters()
          Returns a MethodParameters instance with no parameters.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFactory

public ClassFactory()
Method Detail

createClass

public static Class createClass(ClassName name,
                                Modifier modifier,
                                ClassReference superclass,
                                ClassReference[] interfaces)
Returns a new Class instance according to the given characteristics.

Parameters:
name - The name of the class
modifier - The modifier of the class
superclass - The extended superclass of the class
interfaces - The implemented interfaces
Returns:
The new Interface instance

createClassElements

public static ClassElements createClassElements()
Returns a new instance of the ClassElements type.

Implementation note: The class elements instance is of type MutableClassElements.

Returns:
The new ClassElements instance

createField

public static Field createField(ClassReference owner,
                                java.lang.String name,
                                Modifier modifier,
                                ClassReference type)
Returns a new Field instance representing a field of a class or an interface.

Parameters:
owner - The owner of the field
name - The name of the field
modifier - The modifier of the field
type - The type of the field
Returns:
The created Field instance

createInterface

public static Interface createInterface(ClassName name,
                                        Modifier modifier,
                                        ClassReference[] superclasses)
Returns a new Interface instance according to the given characteristics.

Parameters:
name - The name of the class
modifier - The modifier of the class
superclasses - The extended superclass interfaces.
Returns:
The new Interface instance

createMethod

public static Method createMethod(ClassReference owner,
                                  java.lang.String name,
                                  Modifier modifier,
                                  ClassReference type,
                                  MethodParameters parameters)
Returns a new Method instance representing a method of a class or an interface.

Parameters:
owner - The owner of the method
name - The name of the method
modifier - The modifier of the method
type - The type of the method
parameters - The parameters of the method
Returns:
The created Method instance

createParameters

public static MethodParameters createParameters(ClassReference[] parameters)
Returns a MethodParameter instance describing the given parameter signature (types).

Implementation note: The instances of no parameter and single parameter signatures are implemented using the flyweight pattern.

Parameters:
parameters - The types of the parameters.
Returns:
The MethodParameter instance describing the given parameter signature.

getEmptyParameters

public static MethodParameters getEmptyParameters()
Returns a MethodParameters instance with no parameters.

Returns:
The MethodParameters instance with no parameters