From aa3037a417180f938c51a4feae23e2dc50b9e836 Mon Sep 17 00:00:00 2001 From: "marten.hedborg" Date: Sun, 15 Mar 2015 20:05:44 +0100 Subject: Better javadoc for Callback class --- src/main/javassist/tools/Callback.java | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/javassist/tools/Callback.java b/src/main/javassist/tools/Callback.java index 4a1a491f..96728913 100644 --- a/src/main/javassist/tools/Callback.java +++ b/src/main/javassist/tools/Callback.java @@ -9,8 +9,26 @@ import java.util.UUID; /** * Creates bytecode that when executed calls back to the instance's result method. * - * Inserts callbacks in CtBehaviour - * + * Example of how to create and insert a callback: + *
{@code
+ * ctMethod.insertAfter(new Callback("Thread.currentThread()") {
+ *     @literal@Override
+ *     public void result(Object... objects) {
+ *         Thread thread = (Thread) objects[0];
+ *         // do something with thread...
+ *     }
+ * }.sourceCode());
+ * }
+ * Contains utility methods for inserts callbacks in CtBehaviour, example: + *
{@code
+ * insertAfter(ctBehaviour, new Callback("Thread.currentThread(), dummyString") {
+ *     @literal@Override
+ *     public void result(Object... objects) {
+ *         Thread thread = (Thread) objects[0];
+ *         // do something with thread...
+ *     }
+ * });
+ * }
*/ public abstract class Callback { @@ -22,8 +40,8 @@ public abstract class Callback { * Constructs a new Callback object. * * @param src The source code representing the inserted callback bytecode. - * Can be one or many single statements or blocks each returning one object. - * If many single statements or blocks are used they must be comma separated. + * Can be one or many single statements each returning one object. + * If many single statements are used they must be comma separated. */ public Callback(String src){ String uuid = UUID.randomUUID().toString(); @@ -48,7 +66,7 @@ public abstract class Callback { } /** - * Inserts callback at the beginning of the body. + * Utility method to insert callback at the beginning of the body. * * @param callback The callback * @@ -61,7 +79,7 @@ public abstract class Callback { } /** - * Inserts callback at the end of the body. + * Utility method to inserts callback at the end of the body. * The callback is inserted just before every return instruction. * It is not executed when an exception is thrown. * @@ -77,7 +95,7 @@ public abstract class Callback { } /** - * Inserts callback at the end of the body. + * Utility method to inserts callback at the end of the body. * The callback is inserted just before every return instruction. * It is not executed when an exception is thrown. * @@ -98,7 +116,7 @@ public abstract class Callback { } /** - * Inserts callback at the specified line in the body. + * Utility method to inserts callback at the specified line in the body. * * @param behavior The behaviour to insert callback in * @param callback The callback representing. -- cgit v1.2.3