public class ClassFabImpl extends AbstractFab implements ClassFab
ClassFab
. Hides, as much as possible, the
underlying library (Javassist).Constructor and Description |
---|
ClassFabImpl(CtClassSource source,
javassist.CtClass ctClass) |
Modifier and Type | Method and Description |
---|---|
void |
addConstructor(java.lang.Class[] parameterTypes,
java.lang.Class[] exceptions,
java.lang.String body)
Adds a constructor to the class.
|
void |
addField(java.lang.String name,
java.lang.Class type)
Adds a new field with the given name and type.
|
MethodFab |
addMethod(int modifiers,
MethodSignature ms,
java.lang.String body)
Adds a method.
|
boolean |
containsMethod(MethodSignature ms)
Convenience method for checking whether the fabricated class already contains
a method.
|
MethodFab |
getMethodFab(MethodSignature ms)
Returns a previous defined method so that it can be further enhanced
(perhaps by adding additional catches, etc.).
|
java.lang.String |
toString()
Returns a representation of the fabricated class, including inheritance, fields,
constructors, methods and method bodies.
|
addInterface, convertClass, convertClasses, createClass, getCtClass, getSource
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addInterface, createClass
public ClassFabImpl(CtClassSource source, javassist.CtClass ctClass)
public java.lang.String toString()
toString
in class java.lang.Object
public void addField(java.lang.String name, java.lang.Class type)
ClassFab
public boolean containsMethod(MethodSignature ms)
ClassFab
containsMethod
in interface ClassFab
ms
- the signaturepublic MethodFab addMethod(int modifiers, MethodSignature ms, java.lang.String body)
ClassFab
public MethodFab getMethodFab(MethodSignature ms)
ClassFab
getMethodFab
in interface ClassFab
ms
- the signature of the method previously addedpublic void addConstructor(java.lang.Class[] parameterTypes, java.lang.Class[] exceptions, java.lang.String body)
ClassFab
addConstructor
in interface ClassFab
parameterTypes
- the type of each parameter, or null if the constructor takes no parameters.exceptions
- the type of each exception, or null if the constructor throws no exceptions.body
- The body of the constructor.