Class ObjectTraversal
- java.lang.Object
-
- de.skuzzle.test.snapshots.normalize.ObjectTraversal
-
@API(status=EXPERIMENTAL) public final class ObjectTraversal extends java.lang.ObjectAllows to recursively iterate all members of an actual object. Each member is wrapped into aObjectMemberinstance from which it can be read/modified. How members are discovered is defined by theObjectMembersstrategy interface.Regardless of the used strategy, certain types are always handled specially when discovered while iterating an object's members:
- We never recurse into types of the packages
java.*orjavax.* - As such, we never recurse into primitive wrappers
- When discovering a
Collectiontype, anIterabletype or an array type, we do not recurse into the actual type but iterate the contained elements instead
The actual order of traversal is undefined but deterministic.
Traversal gracefully handles cycles within the object graph. Every actual encountered object instance is only visited once, regardless of how often it is referenced within the object graph.
- Author:
- Simon Taddiken
- See Also:
ObjectMember,ObjectMembers
- We never recurse into types of the packages
-
-
Constructor Summary
Constructors Constructor Description ObjectTraversal()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidapplyActions(java.lang.Object root, ObjectMembers strategy, ObjectMemberAction... actions)static voidapplyActions(java.lang.Object root, ObjectMembers strategy, java.util.Collection<ObjectMemberAction> actions)static java.util.stream.Stream<ObjectMember>members(java.lang.Object root, ObjectMembers strategy)Creates a lazily populated Stream ofobject membersthat are recursively reachable from the given root object.
-
-
-
Method Detail
-
applyActions
public static void applyActions(java.lang.Object root, ObjectMembers strategy, ObjectMemberAction... actions)
-
applyActions
public static void applyActions(java.lang.Object root, ObjectMembers strategy, java.util.Collection<ObjectMemberAction> actions)
-
members
public static java.util.stream.Stream<ObjectMember> members(java.lang.Object root, ObjectMembers strategy)
Creates a lazily populated Stream ofobject membersthat are recursively reachable from the given root object.- Parameters:
root- Root object from which members shall be discovered - may be null.strategy- Strategy for discovering members. Can be obtained from static factories inObjectMembersitself.- Returns:
- Stream of members.
-
-