Errai 3.0.1-SNAPSHOT

org.jboss.errai.codegen
Class SnapshotMaker

java.lang.Object
  extended by org.jboss.errai.codegen.SnapshotMaker

public final class SnapshotMaker
extends Object

Utility class for creating code-generated snapshots of certain types of live value objects. The classes and interfaces that SnapshotMaker works with have the following characteristics:

Author:
Jonathan Fuerth , Mike Brock

Nested Class Summary
static interface SnapshotMaker.MethodBodyCallback
          Callback interface for providing custom method bodies in snapshots.
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeSnapshotAsSubclass

public 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.

Parameters:
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.
Returns:
A Statement representing the value of the object
Throws:
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.

makeSnapshotAsSubclass

public 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.

Parameters:
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.
Returns:
A Statement representing the value of the object
Throws:
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.

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.