public final class SnapshotMaker extends Object
equals(Object)
, which is always ignored)
void
literalizable type
in the current code generator context
Modifier and Type | Class and Description |
---|---|
static interface |
SnapshotMaker.MethodBodyCallback
Callback interface for providing custom method bodies in snapshots.
|
Modifier and Type | Method and Description |
---|---|
static Statement |
makeSnapshotAsSubclass(Object o,
Class<?> typeToSnapshot,
Class<?> typeToExtend,
SnapshotMaker.MethodBodyCallback methodBodyCallback,
Class<?>... typesToRecurseOn)
Code-generates an object whose methods return (snapshots of) the same
values as the given object.
|
static Statement |
makeSnapshotAsSubclass(Object o,
MetaClass typeToSnapshot,
MetaClass typeToExtend,
SnapshotMaker.MethodBodyCallback methodBodyCallback,
MetaClass... typesToRecurseOn)
Code-generates an object whose methods return (snapshots of) the same
values as the given object.
|
public static Statement makeSnapshotAsSubclass(Object o, Class<?> typeToSnapshot, Class<?> typeToExtend, SnapshotMaker.MethodBodyCallback methodBodyCallback, Class<?>... typesToRecurseOn)
o
- The object to snapshot.typeToSnapshot
- The type to read the snapshot attributes from. Must be a
superclass of o or an interface implemented by o, and methods not
supplied by methodBodyCallback
must meed the requirements
laid out in the class-level SnapshotMaker documentation.typeToExtend
- The type of the snapshot to produce. Must be a subclass or
subinterface of typeToSnapshot, and the additional methods present
in typeToExtend vs. typeToSnapshot must be provided by the
MethodMaker callback, since they can't be generated from o.methodBodyCallback
- A callback that can provide method bodies, preventing the standard
snapshot behaviour for those methods. This callback is optional;
null is acceptable as "no callback."typesToRecurseOn
- The types for which the snapshot maker should be applied
recursively.CyclicalObjectGraphException
- if any objects reachable from o
form a reference cycle.
The simplest example of this would be a method on o
that
returns o
itself. You may be able to work around such a
problem by supplying a canned representation of one of the
objects in the cycle.public static Statement makeSnapshotAsSubclass(Object o, MetaClass typeToSnapshot, MetaClass typeToExtend, SnapshotMaker.MethodBodyCallback methodBodyCallback, MetaClass... typesToRecurseOn)
o
- The object to snapshot.typeToSnapshot
- The type to read the snapshot attributes from. Must be a
superclass of o or an interface implemented by o, and methods not
supplied by methodBodyCallback
must meed the requirements
laid out in the class-level SnapshotMaker documentation.typeToExtend
- The type of the snapshot to produce. Must be a subclass or
subinterface of typeToSnapshot, and the additional methods present
in typeToExtend vs. typeToSnapshot must be provided by the
MethodMaker callback, since they can't be generated from o.methodBodyCallback
- A callback that can provide method bodies, preventing the standard
snapshot behaviour for those methods. This callback is optional;
null is acceptable as "no callback."typesToRecurseOn
- The types for which the snapshot maker should be applied
recursively.CyclicalObjectGraphException
- if any objects reachable from o
form a reference cycle.
The simplest example of this would be a method on o
that
returns o
itself. You may be able to work around such a
problem by supplying a canned representation of one of the objects
in the cycle.Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.