1 package org.sourceforge.jemm.weaver.transformation;
2
3 import javassist.CtClass;
4
5 /**
6 * A ClassTransformation uses JavaAssist to update the class byte code.
7 *
8 * All ClassTransformation classes must implement equals and hashcode as they
9 * are stored in collections. The equality checks must make sure that
10 * transformations to do the same thing will result in the equality check
11 * returning true.
12 *
13 * @author <a href="mailto:csuml@yahoo.co.uk">Paul Keeble</a>
14 *
15 */
16 public interface Transformation {
17
18 /**
19 * Modifies the passed in CtClass based on the transformation necessary.
20 *
21 * @param clazz
22 * The CtClass to modify
23 * @throws TransformationException
24 * If an error occurs in the transformation process
25 */
26 void transform(CtClass clazz) throws TransformationException;
27
28 /**
29 * Should return a list of the transformations that this transform requires before
30 * it can execute on a class.
31 *
32 * For the core Transformations this is equal to getClass().getSimpleName().
33 * @return A list of transforms that must run first.
34 */
35 String[] dependentTransforms();
36
37 /**
38 * When the dependencies for a Transformation are being determined it is this name
39 * which should be listed in the dependency list. The name can be anything but AbstractClassTransformation
40 * implements this as getClass().getSimpleName() which is used in many of the transformations.
41 *
42 * @return The name of the transformation used in dependency matching
43 */
44 String getTransformationName();
45
46
47 /**
48 * Note that the equals check is not just about equality, but whether the
49 * transforms are equivalent. Any equivalent transforms, even if a different
50 * object should result in a true return.
51 *
52 * @see Object#equals(Object) For the definition of equals
53 * @see AbstractClassTransformation Which implements a default equals and
54 * hashcode
55 * @param obj
56 * the object to check for equality.
57 * @return True if equal, false otherwise
58 */
59 boolean equals(Object obj);
60
61 /**
62 * @see Object#hashCode()
63 * @return The hashcode
64 */
65 int hashCode();
66 }