org.jboss.errai.codegen
Interface SnapshotMaker.MethodBodyCallback
- Enclosing class:
- SnapshotMaker
public static interface SnapshotMaker.MethodBodyCallback
Callback interface for providing custom method bodies in snapshots. There are three major use cases:
- To implement methods that take parameters (snapshots of
these methods cannot be generated automatically)
- To return a reference to some object that's already in the
scope of the snapshot (such as a reference to a parent object
from a getParent() method)
- To implement additional methods in the case that the snapshot
type is not the same as the type to extend.
- Author:
- Jonathan Fuerth
generateMethodBody
Statement generateMethodBody(MetaMethod method,
Object o,
ClassStructureBuilder<?> containingClass)
- Optionally returns the statement that should be used as the body of the
given method for the given object's snapshot. If the default snapshot
behaviour provided by SnapshotMaker is sufficient for the given method,
this callback can simply return null.
- Parameters:
method
- The method to provide the body for.o
- The instance object that we are taking the snapshot of. You can
use this reference if you need to invoke method
.containingClass
- The class that will contain the generated method. During the
callback, you can generate additional methods and fields within
this class if you like.
- Returns:
- The Statement to use as the method body (must return a type
compatible with
method
's return type), or null if the
snapshot maker should generate the method body by invoking method
on o
and returning a Literal of its value.
Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.